Welcome! Log In Create A New Profile

Advanced

Double Redirect

June 19, 2016 05:12PM
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
Subject Author Posted

Double Redirect

Lebod June 19, 2016 05:12PM

Re: Double Redirect

itpp2012 June 19, 2016 05:16PM

Re: Double Redirect

Lebod June 20, 2016 05:05PM

Re: Double Redirect

itpp2012 June 20, 2016 05:51PM

Re: Double Redirect

Lebod June 20, 2016 05:59PM

Re: Double Redirect

itpp2012 June 20, 2016 06:24PM

Re: Double Redirect

Francis Daly June 19, 2016 07:16PM

Re: Double Redirect

Lebod June 24, 2016 12:45AM

Re: Double Redirect

Francis Daly June 24, 2016 08:32PM

Re: Double Redirect

Lebod June 25, 2016 01:42AM

Re: Double Redirect

Edho Arief June 25, 2016 01:52AM

Re: Double Redirect

Lebod June 25, 2016 05:09PM

Re: Double Redirect

Edho Arief June 25, 2016 10:50PM

Re: Double Redirect

Lebod June 26, 2016 12:48PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 174
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready