Report this

What is the reason for this report?

Serving two different root folders from ngix

Posted on April 26, 2018
Pera

By Pera

Hi, I’ve got a working server running nginx with the site information below

server { listen 80; listen [::]:80;

    root /var/www/app1/public;

    index index.php;

    server_name 12.23.456.789;

    location / {
    try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
    }


    location ~ /\.ht {
    deny all;
    }

}

server { listen 8080; listen [::]:8080;

    root /var/www/app2/public;

    index index.php;

    server_name 12.23.456.789;

    location / {
    try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
    }


    location ~ /\.ht {
    deny all;
    }

}

Unfortunately I can not manage the get the same working setup in DigitalOcean Droplet… Any ideas might might be the case or what am I missing? Just getting errors about conflicting server name

conflicting server name “12.23.456.789” on 0.0.0.0:80, ignored conflicting server name “12.23.456.789” on [::]:80, ignored conflicting server name “12.23.456.789” on 0.0.0.0:8080, ignored conflicting server name “12.23.456.789” on [::]:8080, ignored



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Find a fix (at least a temporary one). I’m using a floating ip as the other servername. Seems to work…

EDIT: The config you copy/pasted above should actually work. There must be duplicate copies of your config, basically a place where you are defining a server block with the same server_name and port twice.

Take a look at this tutorial for complete context on nginx config for multiple sites: https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

nginx config would fail with the error conflicting server name if you have multiple server {} blocks with the same PORT and SERVER_NAME lines.

nginx config could be in files in /etc/nginx/sites-enabled/default or in /etc/nginx/conf.d - take a look and confirm that there are no places where you are defining the same port and server_name in two different server{} blocks.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.