I have been scratching my head off as all of the forums are saying that following simple code should work for redirecting all traffic from HTTPS to HTTP except one location (Nginx: force SSL on one path, non-SSL on others) but in my case it is not working as expected
It is Magento site having following nginx configuration
upstream examplecombackend {
server unix:/var/run/php-fcgi-examplecom.sock;
}
server {
listen 111.11.111.111:80;
server_name example.com *.example.com;
access_log /home/www/vhosts/example.com/logs/access.log;
error_log /home/www/vhosts/example.com/logs/error.log;
root /home/www/vhosts/example.com/httpdocs;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location /checkout/ {
rewrite ^ https://$host$request_uri? permanent;
}
location @handler {
rewrite / /index.php;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ {
if (!-e $request_filename) {
rewrite / /index.php last;
}
expires off;
fastcgi_pass examplecombackend;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 111.11.111.111:443 ssl;
ssl_certificate /etc/nginx/ssl/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
server_name example.com *.example.com;
root /home/www/vhosts/example.com/httpdocs;
location / {
rewrite ^ http://$host$request_uri? permanent;
}
location /checkout/ {
}
}
Now, after doing this when I go to SSL https://example.com/ it correctly forwards to Non- SSL http://example.com/ but if I go to https://example.com/checkout it says
404 Not Found
nginx/1.8.1
Not sure what I am missing here....