Need to resolve this asap, this is basic setup but does not work, please have a look at config files below. site is looping between www and non-www until firefox of chrome stops it:
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
here is my nginx.conf
user xxxxxxx; worker_processes 1; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf;
events { worker_connections 1024; multi_accept on; }
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
server_tokens off;
client_max_body_size 16m;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
gzip_proxied any;
gzip_comp_level 2;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server { listen 80 default_server; listen [::]:80 default_server; server_name _; return 444; }
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Heya,
If your website is stuck in a redirect loop between the www and non-www versions, it’s usually because your server configuration is telling it to redirect from www to non-www and vice versa. This is a common problem, and can often be resolved by carefully examining your server block configurations.
The part of your configuration that is responsible for the redirect loop might not be included in your main nginx.conf file. The redirect rules are typically located in the server blocks for the specific sites, which are included in the ‘sites-enabled’ directory.
Let’s assume that you want to redirect all www requests to the non-www version of your site. Your server block might look like this:
Here, the first
server
block matches requests to www.example.com and redirects them (with a 301 - Permanent Redirect) to example.com. The secondserver
block is the one that actually handles requests to example.com.Remember to replace ‘example.com’ with your own domain name.
After making changes, don’t forget to test your configuration with
sudo nginx -t
and if everything is okay, reload your Nginx configuration withsudo service nginx reload
orsudo systemctl reload nginx
, depending on your system.