【发布时间】:2019-05-07 15:10:00
【问题描述】:
当我在浏览器中点击该 URL 时,我不断从 nginx 收到此错误,但我不明白的部分是我的配置中没有任何重写。此外,我在 nginx 的错误日志中也没有得到任何相关信息。我在下面分享我的配置:
# Force HTTP requests to HTTPS
server {
listen 80;
server_name mywebsite.intweb.net;
return 301 https://mywebsite.intweb.net$request_uri;
}
server {
listen 443 ssl;
root /var/opt/httpd/lbdocs;
server_name mywebsite.intweb.net ;
# add Strict-Transport-Security to prevent man in the middle attacks
add_header Strict-Transport-Security "max-age=31536000" always;
ssl_certificate /etc/pki/tls/certs/star_intweb_net.pem;
ssl_certificate_key /etc/pki/tls/certs/star_intweb_net.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
access_log /var/log/nginx/lblogs/https/access.log;
error_log /var/log/nginx/lblogs/https/error.log;
# include rewrites/mywebsite.com.conf;
index index.php index.html index.htm;
# Make nginx serve static files instead of Apache
# NOTE this will cause issues with bandwidth accounting as files wont be logged
location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css)$ {
expires max;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
# proxy the PHP scripts to Apache listening on <serverIP>:8080
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location ~ /\. {
deny all;
}
谢谢
【问题讨论】:
-
这是一个 WordPress 网站吗?
-
127.0.0.1:8080 是您的后端服务器吗?
-
@IvanShatsky 是的
-
@Light.G 是的,我在后端运行了 apache,但是当我向后端发送 ssl 请求时没有发生这种情况,直到我将其更改为纯 HTTP,如您所见与127.0.0.1:8080
-
作为一种快速解决方法,在您当前主题的
functions.php文件的开头添加remove_action('template_redirect', 'redirect_canonical');。
标签: wordpress nginx nginx-config