Tutorial by Examples

server { listen 80 default_server; listen [::]:80 default_server; server_name example.com www.example.com; return 307 https://$host$request_uri; } A 301 redirect is also an alternative but if a POST is made to a 301, then many clients will resubmit the request as a GET - whic...
server { server_name example.com; return 301 $scheme://example.net$request_uri; }
Nginx configuration to detect request from mobile user-agent and redirect them to mobile site. location / { #mobile site handling as per user agent set $mobile_rewrite do_not_perform; // variable to store action. default set to not perform redirection to mobile site. if ($htt...
HTTPS server with http location: server { listen 443; root /var/www/ location / { ... } location /http { rewrite ^ http://$host$request_uri? permanent; } } HTTP server redirects to HTTPS except one location: server { root /var/www/ locat...
Use Nginx map to parse fields and reject requests. # Allowed hosts map $http_host $name { hostnames; default no; example.com yes; *.example.com yes; example.org yes; *.example.org yes; .example.net yes; wap.* yes; } # Allowed count...

Page 1 of 1