Report this

What is the reason for this report?

nginx domain resolves to incorrect site

Posted on March 31, 2014

I’m trying to host two domains on a single droplet. domainA.com and domainB.com

domainA.com correctly shows content from /home/public/domainA/index.php correctly. domainB.com just shows domainA.com, whereas it should be showing the content of /home/public/domainB/index.php.

Both domains are using digitaloceans nameservers, have an entry in sites-available and sites-enabled.

domainA nginx config:

server { listen 80;

    root /home/public/domainA/;
    index index.php index.html index.htm;

    server_name domainA.com www.domainA.com;

domainB nginx config:

server { listen 80

    root /home/public/domainB/;
    index index.php index.html index.htm;

    server_name domainB.com www.domainB.com;

Any help resolving this matter would be much appreciated!

Thanks



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.

Is that your entire configuration? You must have some PHP path for the .php files to work, ensure the root for that is set accordingly too.

This is just my quick resonse… Move the server name just below the port. Nginx reads configs in order, so that might make a difference… cause nginx would read… port 80… CHECK… go to this root (domainA). If you move it above you are doing Port 80… CHECK… domainA… FALSE… domainB… CHECK… <br> <br>

semicolon is missing after this line of domainB.com’s config: <br> <br>listen 80

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.