Double Redirect

Lebod nginx-forum at forum.nginx.org
Sat Jun 25 21:09:03 UTC 2016


Echo Arief,

Thanks for the reply.
My complete set up is below. The only difference is the use of "example.com"
instead of the domain for privacy reasons.I was really hoping that a
gracious person would just point out the mistake in the set up if there is
one...

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; 
} 
}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,267700,267877#msg-267877



More information about the nginx mailing list