admin管理员组文章数量:1392007
thanks for any help. I am not a server guy but I am dealing with a server at the moment. I have a site that is in a redirect loop from www to non-www. I am using a DigitalOcean Droplet with Ubuntu and Nginx for SSL. I originally had issues getting the SSL working and have created a config based on this post on StackExchange: Wordpress redirect loop on nginx + apache reverse proxy. The main difference I had done was used a 302 redirect in the last server block. However someone told me to change it to 301 and now I am getting the loop from www to non-www. Below is my config file.
server {
server_name .mysite;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html;
gzip on;
gzip_types application/javascript image/* text/css;
gunzip on;
location ~\.(js|css|png|jpg|jpeg) {
try_files $uri $uri/ =404;
}
location / {
try_files $uri @apache;
}
location ~[^?]*/$ { # proxy directories
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location ~ \.php$ { # serve php files
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location @apache { # used by location /
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/mysite/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mysite/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
listen 80;
server_name _;
return 301 https://$host$request_uri;
}
Note: changing the 301 back to 302 did not fix the problem.
Please help, thank you!
Edit: I have also confirmed there are no references to www.mysite in the database. I have used WP-CLI to find any. And the Home and Site URLs have always been without www.
本文标签: ssl301 Redirect Loop www to nonwwwNginxApache2
版权声明:本文标题:ssl - 301 Redirect Loop www to non-www - Nginx + Apache2 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744773893a2624507.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论