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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744773893a4592927.html
评论列表(0条)