Question
Nginx & Unicorn multiple sinatra apps not working
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/unicorna.sock failtimeout=0;
}
upstream b{
server unix:/var/www/html/b.com/tmp/sockets/unicornb.sock failtimeout=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;
}
errorpage 500 502 503 504 /500.html;
clientmaxbodysize 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;
}
errorpage 500 502 503 504 /500.html;
clientmaxbodysize 4G;
keepalive_timeout 10;
}
Thanks
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.
×
Actually, just found the answer here ....
https://www.digitalocean.com/community/questions/dns-configuration-2-domains
I needed a preceding “.”
servername .a.com
.....
servername .b.com