Question
i have a problem setting up subdomains with nginx
hey there i am running the one click installation of django on ubuntu 12.04, i also have installed a ghost blog on the same vps, but when configuring the available-sites on nginx i have come to a problem.
my regular domain is orlandoalmario.com this one points to my django project
i have the “django” file that come for default with the one click installation in etc/nginx/sites-enabled, to this one i have added another “server” instance to point to the ghost blog when the server name is blog.orlandoalmario.com
but it is not working.
after tweaking a little i discover that it stops working when i use subdomains like *.orlandoalmario.com
when y configured it with another full domain. oalmario.co it works like a charm.
but if i edited the configuration files of nginx with a subdomain in the server_name attributte it fails.
here is how my current sites-available looks like:
upstream app_server {
server 127.0.0.1:9000 fail_timeout=0;
}
server {
listen 80;
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 4G;
# server_name _;
keepalive_timeout 5;
# Your Django project's media files - amend as required
location /media {
alias /home/django/django_project/django_project/media;
}
# your Django project's static files - amend as required
location /static {
alias /home/django/django_project/django_project/static;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
server {
listen 80;
server_name oalmario.co;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:2368;
proxy_redirect off;
}
}
if i change the server name from oalmario.co to blog.orlandoalmario.com ngninx fails to restart it service. (figure that out after a hole day trying)
so ther yo have it. at this point i am pretty clueless thank you for any help you can get me.
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.
×
Hi! Are there any errors in nginx’s error log?
You might need to increase
server_names_hash_bucket_size
in/etc/nginx/nginx.conf
.