我的网站是example.com(例如)
这是我在dockerfile中的nginx配置。
server {
listen 80;
server_name example.com;
location / {
rewrite ^ https://$host:7000$request_uri? permanent;
}
}
server {
listen 443 ssl;
server_name example.com;
gzip on;
gzip_min_length 1000;
gzip_types text/plain text/xml application/javascript text/css;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
root /usr/share/nginx/html;
location / {
add_header Cache-Control "no-store";
try_files $uri $uri/index.html /index.html;
}
location ~ \.(?!html) {
add_header Cache-Control "public, max-age=2678400";
try_files $uri =404;
}
}
现在,我的Docker容器正在主机端口7000和容器端口80上运行。 问题是,如果删除了我的cookie并尝试访问example.com:7000,它将带我到“普通HTTP请求已发送到HTTPS端口400错误请求”。但是,如果我尝试访问https://example.com:7000,则会将我带到激活ssl的正确页面。为什么不重写工作?我还尝试过重写删除7000端口,但仍然没有成功。