因为使用IdentityServer4,所以也配置了HTTPS安全协议。
但是如果俩个都使用的话,一是不好区分,二是没有太多的必要,
所以就想着取消掉HTTP的访问,全部转向安全协议,
使用Nginx重写转发即可轻松实现。
直接看Nginx配置吧:
server {
listen 80;
server_name ids.neters.club;
rewrite ^(.*)$ https://$host$1 permanent;#把http的域名请求转成https
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
}
server {
listen 443 ssl;
server_name ids.neters.club; #网站域名
ssl on;
ssl_certificate 1_ids.neters.club_bundle.crt; #证书公钥
ssl_certificate_key 2_ids.neters.club.key; #证书私钥
#ssl_certificate ids.neters.club.crt;
#ssl_certificate_key ids.neters.club.rsa;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDH:AESGCM:HIGH:!RC4:!DH:!MD5:!3DES:!aNULL:!eNULL;
ssl_prefer_server_ciphers on;
error_page 497 https://$host$uri?$args;
location / {
proxy_pass http://localhost:5004;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Cookie $http_cookie;
#proxy_cookie_path
chunked_transfer_encoding off;
}
}