Reputation: 138
I have an nginx/gunicorn/supervisor/posrgresql server with Django. I server two web pages from this server, with each with its own nginx conf file. I have purchased and downloaded SSL certificates and they are working in some circumstances.
My nginx conf file looks like this:
server {
listen 80;
server_name name.org;
return 301 https://www.name.org;
{
server {
listen 80;
listen 443 ssl;
server_name www.name.org;
ssl_certificate...
}
And so on. What I want to happen is this:
Either
1.) entire site with all pages https
or
2.) one particular sub-page with https, e.g. https://www.name.org/page, no matter how you get there, name.org/page, https://www.name.org/page, www.name.org/page, internal links, etc. The point is I need to serve THAT page over SSL.
Currently, name.org takes you to my home page https. www.name.org does not. I can go to any page on my site, and then enter that page name in the address bar, like https://www.name.org/anypage, and it will reload with the green lock.
I've been looking on stackoverflow, nginx documentation, godaddy (where I purchased my certificates) and everywhere else I can think to search for hours and cannot find anything, so any help will be quite welcome.
Upvotes: 0
Views: 460
Reputation: 1605
Change your first server
block to include the www
subdomain:
server {
listen 80;
server_name name.org www.name.org;
return 301 https://www.name.org;
}
This will redirect both http://name.org
and http://www.name.org
to https://www.name.org
. After you've done that, you can remove the listen 80;
from your second server
block, as the first one covers that name / port combination, and you'll only be dealing with the ssl version from then on.
Upvotes: 1