前言:
环境:nat alpine
端口映射(内网端口——外网端口):
80——18000
443——18443
nginx.conf配置点击“展开(截图看不全,粘贴到wordpress代码又没格式,懒得搞格式了,将就看吧):
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
absolute_redirect off;
ssl_certificate /root/.acme.sh/ghost.gv.uy_ecc/ghost.gv.uy.cer;
ssl_certificate_key /root/.acme.sh/ghost.gv.uy_ecc/ghost.gv.uy.key;
gzip on;
gzip_min_length 1024;
gzip_comp_level 5;
gzip_proxied any;
gzip_vary on;
gzip_http_version 1.1;
gzip_buffers 16 8k;
gzip_types text/plain
text/css
text/xml
text/javascript
application/javascript
application/json;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log warn;
server {
listen 80;
server_name ghost.gv.uy;
return 302 https://$host:18443$request_uri;
}
server {
listen 443 ssl;
server_name ghost.gv.uy;
root /var/lib/nginx/html;
location ~* \.(jpg|jpeg|png|ico|gif|css|js)$ {
root /var/lib/nginx/html;
expires 30d;
add_header Cache-Control "public, no-transform";
access_log off;
}
}
}
排障过程
我在访问网页http://ghost.gv.uy:18000时,本应该会自动跳转到https://ghost.gv.uy:18443,明明前几天重定向是好的,但是现在浏览器误会了,直接跳转到https默认443端口,卡在这儿了

想要清cookie也没有cookie可清

访问https://ghost.gv.uy:18443可以访问,说明是重定向的问题,nginx配置没问题,我也用的是302暂时重定向,每次都向服务器请求一次,也无cookie可清

在浏览器无痕模式访问http的18000端口也是正常跳转到https的18443端口,以下是跳转过程


解决方法
询问codex后,得知是浏览器的历史策略导致的
- 访问 chrome://net-internals/#hsts
- 在 Delete domain security policies 输入 ghost.gv.uy 并删除

之后我就能正常重定向了