【发布时间】:2025-12-09 12:50:01
【问题描述】:
我有一个完整的 nginx 版本安装:Ubuntu 16.04 上的 nginx/1.10.0 (Ubuntu) 除了 /etc/nginx/sites-enabled/default 被以下替换...
server {
listen 443 default_server;
server_name www.example.com;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:8080; # my existing apache instance
proxy_set_header Host $host;
# re-write redirects to http as to https, example: /home
proxy_redirect http:// https://;
}
}
其目的是作为在端口 8080 上运行的 http api 的 https 包装器。
我现在正在尝试这样做,以便当有人通过 http 端口 80 访问我的网站时,它会将他们重定向到 https。我已经尝试过所有其他记录在案的修复程序,主要是基于这样的......
server {
listen 80;
return 301 https://$host$request_uri;
}
...似乎没有任何效果,而且您总是会看到 WELCOME TO NGINX 页面。
【问题讨论】:
-
是的,尝试过但失败了。仍然得到 http "Welcome to nginx!"页面