Reputation: 131
I have a cherrypy webapp that I host behind an nginx reverse-proxy with ssl.
The nginx location is set up as such:
location /webapp {
proxy_pass http://127.0.0.1:8642;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Everything works when I load up https://myaddress.com/webapp. The page loads fine.
But when I click on any links, it opens http://myaddress.com/webapp/page, which doesn't load when behind nginx with ssl.
The links are a simple
<a href='/webapp/page'>Page</a>
I can then manually open https://myaddress.com/webapp/page which loads fine.
I can't figure out why the browser is kicking it over to http:// instead of staying on https://
EDIT:
I figured this out (kind of) a while ago and forgot about this post.
Changing the main method name from index() to default() fixed this. I can't figure out why, and I can't find anything in the CherryPy docs for it.
So when going to mysite.com/news Cherrypy now returns News.default() instead of News.index() and this doesn't change the URI.
Upvotes: 1
Views: 1132
Reputation: 5741
Are you enabling the reverse proxy tool?
You can do so by adding into your config file:
tool.proxy.on = True
or by decorating.
@cherrypy.tools.proxy
Part of the functionality of that tool is to adjust the application base by adjusting the protocol from http
to https
.
Upvotes: 3