I have the above config on a Debian droplet. I have a staging site (staging.flashcard101.com) and a live site (flashcard101.com). DNS for both are pointing to the droplet IP address. When I browse to the respective sites, some devices and browsers work fine, but some only show the live content at both domain names. It seems nginx does not direct the traffic correctly each time. Any idea what may be going on, or where I should look to diagnose? Thanks.
Here are my nginx configs: live:
server {
listen 80;
server_name www.flashcard101.com;
location /static {
alias /home/fc/sites/www.flashcard101.com/static;
}
location /media {
alias /home/fc/sites/www.flashcard101.com/media;
}
location / {
proxy_set_header Host $host;
proxy_pass http://unix:/tmp/www.flashcard101.com.socket;
}
}
Staging:
server {
listen 80;
server_name www.staging.flashcard101.com;
location /static {
alias /home/fc/sites/www.staging.flashcard101.com/static;
}
location /media {
alias /home/fc/sites/www.staging.flashcard101.com/media;
}
location / {
proxy_set_header Host $host;
proxy_pass http://unix:/tmp/www.staging.flashcard101.com.socket;
}
}
Gunicorn confs: Live:
description "Gunicorn server for www.flashcard101.com"
start on net-device-up
stop on shutdown
respawn
setuid fc
chdir /home/fc/sites/www.flashcard101.com/source
exec ../venv/bin/gunicorn \
--bind unix:/tmp/www.flashcard101.com.socket \
--access-logfile ../access.log \
--error-logfile ../error.log \
flf.wsgi:application
Staging:
description "Gunicorn server for www.staging.flashcard101.com"
start on net-device-up
stop on shutdown
respawn
setuid fc
chdir /home/fc/sites/www.staging.flashcard101.com/source
exec ../venv/bin/gunicorn \
--bind unix:/tmp/www.staging.flashcard101.com.socket \
--access-logfile ../access.log \
--error-logfile ../error.log \
flf.wsgi:application
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!
I just realized it has to do with using www. or not as a prefix…
I found the answer here - http://nginx.org/en/docs/http/server_names.html
In the nginx/sites-available/ config files add both paths to the server_name:
server {
listen 80;
server_name example.org www.example.org;
...
}
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.