I
I
Ilya Korol2020-05-01 01:48:57
Django
Ilya Korol, 2020-05-01 01:48:57

nginx+https+django=400?

Made a site redirect from port 80 to 443

/etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

/etc/systemd/system/gunicorn.service


[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=root
Group=root
WorkingDirectory=/root/SocialDir
ExecStart=/root/SocialDir/SocialEnv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
Social.wsgi:application

[Install]
WantedBy=multi-user.target

nginx


server {

listen 80;
server_name ..ru;
return 301 https://..ru$request_uri;

}

server {
listen 443;

ssl on;
ssl_certificate /etc/ssl/bundle.crt;
ssl_certificate_key /etc/ssl/..ru.key;

server_name .ru;

access_log /var/log/nginx/nginx.vhost.access.log;
error_log /var/log/nginx/nginx.vhost.error.log;

ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;

location = /favicon.ico {
root /root/favicon;
}

location = /favicon.png {
root /root/favicon;
}

location /static/ {
root /root/SocialDir;
}

location = /manifest.json {
root /root/favicon;
}

location /Images/ {
root /root/SocialDir;
}

location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}

When switching to port 80, a 400 error occurs from the browser with the comment "The plain HTTP request was sent to HTTPS port"
How to fix redirection from port 80 to 443.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2020-05-01
@galaxy

Made a site redirect from port 80 to 443

Where did you make it?
In the nginx config, at first glance, everything is ok.
Is it in iptables??

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question