NGINX配置跳转问题
分类:
入门到放弃
标签:
日期: 2024-02-15 | 作者: admin
| 浏览:
106
申请了个免费的SSL证书,就想着把HTTP的都跳转到HTTPS上,然后想着WWW能省则省了,开始折腾NGINX。
参考配置如下:
# mysite.cn 配置
upstream mysites{
server 127.0.0.1:8888;
}
# HTTP 跳转 HTTPS
server {
listen 80;
server_name mysite.cn www.mysite.cn;
return 301 https://$server_name$request_uri;
}
# WWW 跳转 不带WWW
server {
listen 443;
server_name www.mysite.cn;
return 301 https://mysite.cn$request_uri;
ssl_certificate cert/mysite.cn.crt;
ssl_certificate_key cert/mysite.cn.key;
}
server {
listen 443 ssl;
server_name mysite.cn;
charset utf-8;
# ssl证书存放路径
ssl_certificate cert/mysite.cn.crt;
ssl_certificate_key cert/mysite.cn.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
client_max_body_size 50M;
location /static {
alias /var/www/mysite/static;
}
location /media {
alias /var/www/mysite/media;
}
location / {
uwsgi_pass mysite;
include /var/www/mysite/uwsgi_params;
}
}
相关文章