I'm trying to display my NodeJS application when the user type a specific domain. I already pointed the domain on the server, then I've installed Nginx and I have created a configuration file into:


this have the following content:

server {
        listen 80;
        server_name myapp.it www.myapp.it;

        location / {
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $http_host;
                proxy_pass http://localhost:4568;

I restarted Nginx and I executed this command: nginx -t but I got:

nginx: [warn] conflicting server name "myapp.it" on, ignored
nginx: [warn] conflicting server name "www.myapp.it" on, ignored

when I visit the domain I get 403 Forbidden, that's because Letsencrypt cannot register a certificate for the conflict above. What I did wrong?

  • Use nginx -T (uppercase T) to view the entire configuration across all included files and identify where the conflicting server_name is coming from. Has your editor left a backup file in the conf.d directory perhaps. – Richard Smith Oct 17 '20 at 16:40

You should put the site config files in /etc/nginx/sites-enabled.

To solve your problem, check if you have a default site config in /etc/nginx/sites-enabled and delete it. Then, move your myapp.conf file to /etc/nginx/sites-enabled and restart nginx.

  • You're right! What if I have multiple node js app? Should I create a new conf each time? – sfarzoso Oct 17 '20 at 17:22
  • 1
    I don't know very much about node js apps. If each of them listens in different ports then you could add multiple locations entries in the site config, each with a different port. You sure can also add a new site config file for each app. It's up to you. – Jesús Ángel Oct 17 '20 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.