I have Django + Nginx + Gunicorn on Ubuntu. Certificates generated with Letsencrypt.
In /etc/nginx/sites-available/myproject I have:
server {
server_name myproject.com www.myproject.com;
listen 80;
return 301 https://myproject.com$request_uri;
}
server {
server_name myproject.com www.myproject.com;
listen 443;
ssl on;
ssl_certificate /etc/letsencrypt/live/myproject.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/myproject.com/privkey.pem;
client_max_body_size 1G;
root /home/myname/myproject;
location / {
include proxy_params;
proxy_pass https://unix:/home/myname/myproject/myproject.sock;
}
}
In /etc/nginx/sites-available/default, except commented lines, I have:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
In /etc/nginx/sites-enabled I have default and myproject.
When I go to https://myproject.com, I see “Welcome to nginx!”. What am I doing wrong that it redirects to “Welcome to nginx!”?
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!
Did you try removing default from /etc/nginx/sites-enabled?
sudo rm /etc/nginx/sites-enabled/default
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.