Hi everybody, I'm having an issue with our site. We're trying to redirect all traffic of http://example.com to https://www.example.com. Testing out our site, what happens is that http://example.com redirects to https://example.com which then redirects to https://www.example.com
We also get an error: nginx -t nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignored My server block file is below. I should note that the SSL certificate parameters are handled globally in the nginx.conf file and not in the server block files. server { listen 80; listen 443 ssl; server_name example.com ***IP Address***; return 301 https://www.example.com$request_uri; } server { listen 80; server_name www.example.com; return 301 https://www.example.com$request_uri; } server { listen 443 ssl http2; server_name www.example.com; root /home/forge/example.com/public; index index.html index.htm index.php; charset utf-8; # FORGE CONFIG (DOT NOT REMOVE!) include forge-conf/example.com/server/*; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log off; error_log /var/log/nginx/example.com-error.log error; error_page 404 /index.php; location ~* ^/***A CERTAIN BLOCKED DIRECTORY**** { auth_basic "closed website"; auth_basic_user_file /etc/nginx/htpasswd; allow IP1; allow IP2; allow IP3; allow IP4; deny all; location ~* .(php) { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; include fastcgi_params; } try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; include fastcgi_params; } # Media: images, icons, video, audio, HTC location ~* \.(?:jpg|jpeg|png|gif|ico|css|js|svg|woff)$ { expires 1M; add_header Cache-Control "public"; } # CSS and Javascript location ~* \.(?:css|js)$ { expires 1M; access_log off; add_header Cache-Control "public"; } # cache.appcache, your document html and data location ~* \.(?:manifest|appcache|html?|xml|json)$ { expires -1; # access_log logs/static.log; # I don't usually include a static log } location ~ /\.ht { deny all; } if ($allowed_country = no) { return 444; } } I was wondering if there was an issue in our setup that's causing the double redirect and the error: nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignored Thank you for your help in advance Lebod Posted at Nginx Forum: https://forum.nginx.org/read.php?2,267700,267700#msg-267700 _______________________________________________ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx