Rewrite single page https to http Nginx
I've used something similar to the following, which avoid's IfIsEvil and uses return instead of rewrite
. However it fails DRY, which bothers me.. Suggestions welcome.
server { listen 80; server_name .example.com; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock ; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}server { listen 443 ssl; server_name .example.com; ssl_certificate /etc/ssl/certs/example.com.cert; ssl_certificate_key /etc/ssl/private/example.com.key; index index.html index.htm index.php; # Rewrite only / to http location = / { return 301 http://$server_name$request_uri; } location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock ; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}
See also