-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] HOST url scheme without https #93
Comments
I think you're right that your issue stems from how you use nginx. According to the docs, it looks like I'm using gunicorn without nginx in front of it, and redirect everything in my DNS to https, so |
The way this is handled in Django is leveraging a secure header (e.g. one you have scrubbed and maintained as safe, typically Lines 43 to 47 in f484c2a
|
To fix this issue, you can try updating your nginx configuration to add the X-Forwarded-Proto header. This will enable django-robots to correctly detect the protocol used and generate the correct Host value in the robots.txt file. Here's an example of how to update your nginx configuration: location / { This will set the X-Forwarded-Proto header to the value of $scheme, which should be https when using HTTPS. Django will then use this header to correctly detect the protocol and generate the correct Host value in the robots.txt file. It looks like the issue you're encountering is due to the fact that your Django application is not aware of the fact that it's being served over HTTPS by Nginx. When the header X-Forwarded-Proto is not properly set, Django assumes the request is coming over HTTP, hence the resulting Host using the incorrect scheme in the robots.txt. To fix this, you have a couple of options:
After making the necessary changes, restart your Nginx and Django services to ensure your changes take effect. |
Hello!
I am using django + nginx + https
if set
ROBOTS_USE_SCHEME_IN_HOST = True
I get this result in the robots.txt:
Host: http://site.com
But expected:
Host: https://site.com
Maybe it happens because of using nginx.
nginx proxies traffic to gunicorn via http
How i can fix it?
The text was updated successfully, but these errors were encountered: