Hello, I followed the response to this question: https://www.digitalocean.com/community/questions/nginx-and-unicorn-multiple-rails-apps
But, all requests to b.com go directly to a.com ! I’ve confirmed a different socket is running for each app.
Another thing to note, if I reverse the order of server blocks, then all a.com requests go to b.com.
This is the nginx.conf file. I’m on Ubuntu 12.04. The apps are both SInatra apps.
Where have I gone wrong?
upstream a { server unix:/var/www/html/a.com/tmp/sockets/unicorn_a.sock fail_timeout=0; }
upstream b{ server unix:/var/www/html/b.com/tmp/sockets/unicorn_b.sock fail_timeout=0; }
server { listen 80;
server_name a.com;
root /var/www/html/a.com/public;
try_files $uri @a_app;
location @a_app{
# pass to the upstream unicorn server mentioned above
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://a;
} error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; }
server { listen 80;
server_name b.com;
root /var/www/html/b.com/public;
try_files $uri @b_app;
location @b_app{
# pass to the upstream unicorn server mentioned above
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://b;
} error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; }
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!
This question was answered by @scott.mennealy:
Actually, just found the answer here … https://www.digitalocean.com/community/questions/dns-configuration-2-domains
I needed a preceding “.”
server_name .a.com … server_name .b.com
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.