我最初将 Nginx 配置设置为自动将 HTTP 重定向到 HTTPS。由于我的工作安全策略和 Cloudflare 集成,HTTPS 无法在我的网络内解析。
我只想删除强制重定向到 HTTPS。但是在用 URI 重写注释掉块后,服务器仍然会自动重定向。
这是我的 Nginx 默认配置
#HTTPS redirect (if necessary)
#server {
# listen 80;
# server_name example.com;
# rewrite ^ https://$server_name$request_uri? permanent;
#}
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
listen 443 ssl spdy;
root /var/www/example/current/public;
index index.php index.html index.htm;
spdy_chunk_size 8k;
spdy_headers_comp 7;
server_name example.com;
# Point to ssl certificates
ssl_certificate /root/example.com.crt;
ssl_certificate_key /root/example.com.key;
# Allow only secure TLS protocols
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#ssl_prefer_server_ciphers on;
#ssl_ciphers …Run Code Online (Sandbox Code Playgroud)