i'm facing a problem with nginx rewrites after i migrate my Magento website from Apache to Nginx!
When i add a product to the cart and i press the button Place the order is giving me 500 internal server error !
I opened my logs and i can see this error message :
2017/05/26 13:03:39 [error] 48314#48314: *4022 could not find named location "@handler", client: 81.149.36.86, server: abcsports.co.uk, request: "GET /index.php/checkout/onepage/ HTTP/1.1", host: "www.....", referrer: "http://www........"
My conf file is looking like that :
Redirect to www.
server { listen 80; server_name abcsports.co.uk; return 301 $scheme://www.$host$request_uri; }
Set FPM pool socket for Magento Dashboard, based on adminhtml cookie
map $http_cookie $phpfpm_socket { default unix:/var/run/php-fpm/abcsports.co.uk.sock; ~adminhtml unix:/var/run/php-fpm/abcsports.co.uk-admin.sock; }
server { listen 80 default_server; server_name www.abcsports.co.uk media.abcsports.co.uk skin.abcsports.co.uk js.abcsports.co.uk; # root /var/www/vhosts/abcsports.co.uk/httpdocs; root /var/www/html/abcsports.co.uk/public_html/;
access_log /var/log/nginx/abcsports.co.uk-access.log; error_log /var/log/nginx/abcsports.co.uk-error.log;
client_body_buffer_size 8k; client_max_body_size 10M; client_header_buffer_size 1k; large_client_header_buffers 4 16k;
# SSL Termination if ($server_port = 80) { set $httpss off; } if ($http_x_forwarded_proto = https) { set $httpss on; }
location / { index index.html index.php; try_files $uri $uri/ @handler; expires 30d; }
location ~ ^/(app|includes|media/downloadable|pkginfo|report/config.xml|var)/ { deny all; }
location /. { return 404; }
location @handler { rewrite / /index.php; } #location ~ .php/ { rewrite ^(.*.php)/ last; }
location ~ .php$ { #if (!-e $request_filename) { rewrite / /index.php last; } expires off; fastcgi_pass $phpfpm_socket; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param MAGE_RUN_CODE default; fastcgi_param MAGE_RUN_TYPE store; fastcgi_param HTTPS $httpss; include fastcgi_params; fastcgi_buffer_size 32k; fastcgi_buffers 512 32k; fastcgi_read_timeout 300; } }
server { listen 443 ssl; server_name abcsports.co.uk www.abcsports.co.uk media.abcsports.co.uk skin.abcsports.co.uk js.abcsports.co.uk; root /var/www/html/abcsports.co.uk/public_html/; ssl on; ssl_certificate /etc/ssl/certs/abcsports.co.uk.pem; ssl_certificate_key /etc/ssl/certs/abcsports.co.uk.key;
access_log /var/log/nginx/abcsports.co.uk-ssl-access.log; error_log /var/log/nginx/abcsports.co.uk-ssl-error.log;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}}
I looked everywhere on the internet and i read a lot of things but didn't find the solution ! I would appreciate any help !
Thank you !
Best Answer
(1) This configuration file is derived from your file and is created with the assumption that you want to force SSL on your primary domain, abcsports.co.uk. This is recommended.
(2) I moved the subdomains, "media.abcsports.co.uk, skin.abcsports.co.uk, and js.abcsports.co.uk" into separate server blocks. By default, SSL is not forced for these subdomains, but you could enable the redirections as instructed in the configuration file. Ensure that the SSL certificates for abcsports.co.uk is applicable to the subdomains before activating the SSL block for the subdomains.
(3) There could be errors. Use the error log to debug them.
(4) Backup the current vhost file because using this one. You can do this during a low traffic period.
Expecting your feedback. Cheers!