This is about an sample Rails app that uses subdomains. You can access it here: http://rodrigora.com.br. In this app, you can create site and specify one subdomain for it.
Example:
site:
subdomain:
gog
This site should be accessible by http://gog.rodrigora.com.br
But, the app is unreacheable for any subdomain, neither www
.
DNS server configuration:
nginx server configuration:
upstream app_server {
server unix:/tmp/unicorn.blog.sock fail_timeout=0;
}
server {
listen 80 default;
#server_name localhost;
client_max_body_size 4G;
keepalive_timeout 10;
root /home/ubuntu/apps/blog/current/public;
try_files $uri/index.html $uri.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
# Rails error pages
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/ubuntu/apps/blog/current/public;
}
location ~ ^/(assets)/ {
root /home/ubuntu/apps/blog/current/public;
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
}
Extra information: If I access www.rodrigora.com.br
on browser, Google Chrome show the not found page,but nginx
logs this line:
186.210.71.46 - - [21/Sep/2013:22:08:37 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36"
Questions:
So, nginx is saying that the
www
subdomain is not there?How to configure this app to respond to any subdomain?
Resources: