Htacces index.php?this_path=$1 - .htaccess

Help to translate htaccess
RewriteEngine on
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteRule ^(^[^.]+)$ /index.php?this_path=$1 [L]
Convector site (http://winginx.ru/htaccess) takes me to:
location / {
rewrite ^/(^[^.]+)$ /index.php?this_path=$1 break;
}
In error.log apache
2013/11/08 16:29:28 [error] 23867#0: *30 "/var/www/site.ru/web/tourfirms/index.html" is not found (2: No such file or directory), client: 92.248.243.0, server: site.ru, request: "GET /tourfirms/ HTTP/1.1", host: "www.site.ru"
Config nginx
server {
listen *:80;
server_name site.ru www.site.ru;
root /var/www/site.ru/web;
index index.html index.htm index.php index.cgi index.pl index.xhtml;
error_page 400 /error/400.html;
error_page 401 /error/401.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 405 /error/405.html;
error_page 500 /error/500.html;
error_page 502 /error/502.html;
error_page 503 /error/503.html;
recursive_error_pages on;
location = /error/400.html {
internal;
}
location = /error/401.html {
internal;
}
location = /error/403.html {
internal;
}
location = /error/404.html {
internal;
}
location = /error/405.html {
internal;
}
location = /error/500.html {
internal;
}
location = /error/502.html {
internal;
}
location = /error/503.html {
internal;
}
error_log /var/log/ispconfig/httpd/site.ru/error.log;
access_log /var/log/ispconfig/httpd/site.ru/access.log combined;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /stats {
index index.html index.php;
auth_basic "Members Only";
auth_basic_user_file /var/www/site.ru/stats/.htpasswd_stats;
}
location ^~ /awstats-icon {
alias /usr/share/awstats/icon;
}
location ~ \.php$ {
try_files /9d53b9291759bd903e7bd04ed227882a.htm #php;
}
location #php {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9021;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
location / {
rewrite ^/(^[^.]+)$ /index.php?this_path=$1 break;
}
}

Related

Why is Node JS outperforming Nginx serving big static files (videos) on localhost?

I've developed an infotainment system for buses where all the Android devices are wirelessly connected to a local Linux (Ubuntu) host. I'm using Nginx to serve the videos and the average size of a video is about 800 Mbs. I just developed a Node app with clusters to serve the same videos, and to check which one, Ngnix or Node, will be a better option. To see the difference, I tested the Nginx servers on localhost and they give me a download speed of 120 MBps, while the download speed of the same files (videos) for Node app on localhost is 450 Mbps. Tests were carried out on the same machine of course. My question is, Nginx is faster than Node, right? Shouldn't it be the other way around? And to the best of my understanding, there's nothing wrong with my Nginx configuration and Ngnix has the rights to CD into the folders. I've tried so many different things with Ngnix but nothing seems to work. This is my Nginx conf file.
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
aio threads;
directio 16M;
output_buffers 2 1M;
sendfile on;
sendfile_max_chunk 512k;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_body_buffer_size 10K;
client_header_buffer_size 1k;
client_max_body_size 8m;
large_client_header_buffers 4 4k;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
And this is node app code with clustering, very minimal and basic
try {
app.use ("/videos", express.static(videoFolder))
} catch (e) {
console.log("error in video server:", e.toString())
}
And this is my Ngnix default file inside "sites available" folder
upstream my-stream {
server 127.0.0.1:6000;
server 127.0.0.1:6020;
server 127.0.0.1:6030;
server 127.0.0.1:6040;
server 127.0.0.1:6050;
server 127.0.0.1:6060;
server 127.0.0.1:6070;
server 127.0.0.1:6080;
}
server {
listen 12000;
server_name _;
#access_log /var/log/nginx/access.log mycustomformat;
location / {
proxy_pass http://my-stream;
proxy_max_temp_file_size 0;
}
}
server {
listen 6000;
server_name 127.0.0.1;
location /videos/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /audio/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /ebooks/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /test/ {
return 200 "coming from 6000";
}
}
server {
listen 6020;
server_name 127.0.0.1;
location /videos/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /audio/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /ebooks/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /test/ {
return 200 "coming from 6020";
}
}
server {
listen 6030;
server_name 127.0.0.1;
location /videos/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /audio/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /ebooks/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /test/ {
return 200 "coming from 6030";
}
}
server {
listen 6040;
server_name 127.0.0.1;
location /videos/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /audio/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /ebooks/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /test/ {
return 200 "coming from 6030";
}
}
server {
listen 6050;
server_name 127.0.0.1;
location /videos/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /audio/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /ebooks/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /test/ {
return 200 "coming from 6030";
}
}
server {
listen 6060;
server_name 127.0.0.1;
location /videos/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /audio/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /ebooks/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /test/ {
return 200 "coming from 6030";
}
}
server {
listen 6070;
server_name 127.0.0.1;
location /videos/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /audio/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /ebooks/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /test/ {
return 200 "coming from 6030";
}
}
server {
listen 6080;
server_name 127.0.0.1;
location /videos/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /audio/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /ebooks/ {
root "/home/khan/Desktop/bus data";
autoindex off;
}
location /test/ {
return 200 "coming from 6030";
}
}

Securing .ini files from Public Access with NGINX

We are trying to make ini files that are under the web root unable to be accessed by the public. Currently we have the following config
server {
client_max_body_size 100M;
root /var/www/html/WP;
index index.php index.html index.htm
index.nginx-debian.html;
server_name example.com;
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location ~ \.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$ {
return 404;
}
location = /favicon.ico { log_not_found off; access_log
off; }
location = /robots.txt { log_not_found off; access_log off;
allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name example.com;
return 404; # managed by Certbot
}
We have tried many of the solutions here on Stack overflow, but the files are still public.

Running an ASP.NET application on Linux using mono and mono-fastcgi-server4 in combination with NGINX

I am trying to run an ASP.NET application in a Linux Docker container. For that I use a mono image (mono:5.12) and install a mono-fastci-server4 on it. Another container runs an NGINX proxy, mapping subdirectories to containers. This works well for proxy_pass which I use for my Jenkins and Git containers, but it doesn't work for fastcgi_pass, at least not for more than one subdirectory.
To be more exact:
As long as I run the assignment container behind one subdirectory, everything works perfectly fine, but when I put it behind two subdirectories everything breaks. I feel really lost and would appreciate any help!
First my working configuration:
NGINX.config (generated in my docker container)
upstream assignment {
server 10.0.0.8:9000;
}
upstream course-git {
server 10.0.0.4:8080;
}
upstream course-jenkins {
server 10.0.0.10:8080;
}
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
default $http_x_forwarded_proto;
'' $scheme;
}
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port {
default $http_x_forwarded_port;
'' $server_port;
}
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
default upgrade;
'' close;
}
# Apply fix for very long server names
server_names_hash_bucket_size 128;
# Default dhparam
ssl_dhparam /etc/nginx/dhparam/dhparam.pem;
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl {
default off;
https on;
}
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
log_format vhost '$host $remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
access_log off;
resolver 127.0.0.11;
server {
server_name _;
listen 80;
access_log /var/log/nginx/access.log vhost;
location /assignment {
root /;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param PATH_INFO "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass assignment;
}
location /course/git {
proxy_pass http://course-git/course/git;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
}
location /course/jenkins {
proxy_pass http://course-jenkins/course/jenkins;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
}
}
Start Script of mono-fastcgi-server4
echo "#!/bin/sh\nexport MONO_OPTIONS="--debug"\nfastcgi-mono-server4 /applications=/assignment:/course/assignment /socket=tcp:\$(ip -4 addr show \$BIND_TO| grep -Po 'inet \K[\d.]+'):9000 /verbose=True /printlog=True" > /opt/mono-fastcgi
Now the broken one:
NGINX.config (generated in my docker container)
upstream course-assignment {
server 10.0.0.14:9000;
}
upstream course-git {
server 10.0.0.10:8080;
}
upstream course-jenkins {
server 10.0.0.4:8080;
}
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
default $http_x_forwarded_proto;
'' $scheme;
}
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port {
default $http_x_forwarded_port;
'' $server_port;
}
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
default upgrade;
'' close;
}
# Apply fix for very long server names
server_names_hash_bucket_size 128;
# Default dhparam
ssl_dhparam /etc/nginx/dhparam/dhparam.pem;
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl {
default off;
https on;
}
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
log_format vhost '$host $remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
access_log off;
resolver 127.0.0.11;
server {
server_name _;
listen 80;
access_log /var/log/nginx/access.log vhost;
location /course/assignment {
root /;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param PATH_INFO "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass course-assignment;
}
location /course/git {
proxy_pass http://course-git/course/git;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
}
location /course/jenkins {
proxy_pass http://course-jenkins/course/jenkins;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
}
}
Start Script of mono-fastcgi-server4
echo "#!/bin/sh\nexport MONO_OPTIONS="--debug"\nfastcgi-mono-server4 /applications=/course/assignment:/course/assignment /socket=tcp:\$(ip -4 addr show \$BIND_TO| grep -Po 'inet \K[\d.]+'):9000 /verbose=True /printlog=True" > /opt/mono-fastcgi
The error I get when trying to access the assignment container through my NGINX proxy is the following:
System.InvalidOperationException
Failed to map path '/course/_ViewStart.cshtml'
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.
Exception stack trace:
at System.Web.HttpRequest.MapPath (System.String virtualPath, System.String baseVirtualDir, System.Boolean allowCrossAppMapping) [0x0011a] in <eae422b9b12f4162853d52b85a26cb6e>:0
at System.Web.HttpRequest.MapPath (System.String virtualPath) [0x00012] in <eae422b9b12f4162853d52b85a26cb6e>:0
at System.Web.Hosting.HostingEnvironment.MapPath (System.String virtualPath) [0x00033] in <eae422b9b12f4162853d52b85a26cb6e>:0
at System.Web.Hosting.DefaultVirtualPathProvider.FileExists (System.String virtualPath) [0x00013] in <eae422b9b12f4162853d52b85a26cb6e>:0
at System.Web.WebPages.FileExistenceCache.<.ctor>b__4 (System.String path) [0x0000b] in <801d2c34932044b184a3f58959254712>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Web.WebPages.FileExistenceCache.FileExists (System.String virtualPath) [0x0000e] in <801d2c34932044b184a3f58959254712>:0
at System.Web.WebPages.BuildManagerWrapper.ExistsInVpp (System.String virtualPath) [0x00000] in <801d2c34932044b184a3f58959254712>:0
at System.Web.WebPages.BuildManagerWrapper.Exists (System.String virtualPath) [0x00010] in <801d2c34932044b184a3f58959254712>:0
at System.Web.WebPages.VirtualPathFactoryManager.Exists (System.String virtualPath) [0x00016] in <801d2c34932044b184a3f58959254712>:0
at System.Web.WebPages.StartPage.GetStartPage (System.Web.WebPages.WebPageRenderingBase page, System.Web.WebPages.IVirtualPathFactory virtualPathFactory, System.String appDomainAppVirtualPath, System.String fileName, System.Collections.Generic.IEnumerable`1[T] supportedExtensions) [0x00036] in <801d2c34932044b184a3f58959254712>:0
at System.Web.WebPages.StartPage.GetStartPage (System.Web.WebPages.WebPageRenderingBase page, System.String fileName, System.Collections.Generic.IEnumerable`1[T] supportedExtensions) [0x00063] in <801d2c34932044b184a3f58959254712>:0
at System.Web.Mvc.RazorView.RenderView (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer, System.Object instance) [0x000b3] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.BuildManagerCompiledView.Render (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) [0x00067] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x00080] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0000b] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0009b] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters (System.Web.Mvc.ControllerContext controllerContext, System.Collections.Generic.IList`1[T] filters, System.Web.Mvc.ActionResult actionResult) [0x0000a] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass21+<>c__DisplayClass2b.<BeginInvokeAction>b__1c () [0x0008a] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass21.<BeginInvokeAction>b__1e (System.IAsyncResult asyncResult) [0x00041] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[TResult].CallEndDelegate (System.IAsyncResult asyncResult) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1[TResult].End () [0x00029] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult] (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction (System.IAsyncResult asyncResult) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d (System.IAsyncResult asyncResult, System.Web.Mvc.Controller+ExecuteCoreState innerState) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at (wrapper delegate-invoke) System.Web.Mvc.Async.EndInvokeVoidDelegate`1[System.Web.Mvc.Controller+ExecuteCoreState].invoke_void_IAsyncResult_TState(System.IAsyncResult,System.Web.Mvc.Controller/ExecuteCoreState)
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1[TState].CallEndDelegate (System.IAsyncResult asyncResult) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1[TResult].End () [0x00029] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult] (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End (System.IAsyncResult asyncResult, System.Object tag) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Controller.EndExecuteCore (System.IAsyncResult asyncResult) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Controller.<BeginExecute>b__15 (System.IAsyncResult asyncResult, System.Web.Mvc.Controller controller) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1[TState].CallEndDelegate (System.IAsyncResult asyncResult) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1[TResult].End () [0x00029] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult] (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End (System.IAsyncResult asyncResult, System.Object tag) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Controller.EndExecute (System.IAsyncResult asyncResult) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute (System.IAsyncResult asyncResult) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5 (System.IAsyncResult asyncResult, System.Web.Mvc.MvcHandler+ProcessRequestState innerState) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at (wrapper delegate-invoke) System.Web.Mvc.Async.EndInvokeVoidDelegate`1[System.Web.Mvc.MvcHandler+ProcessRequestState].invoke_void_IAsyncResult_TState(System.IAsyncResult,System.Web.Mvc.MvcHandler/ProcessRequestState)
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1[TState].CallEndDelegate (System.IAsyncResult asyncResult) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1[TResult].End () [0x00029] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult] (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End (System.IAsyncResult asyncResult, System.Object tag) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.MvcHandler.EndProcessRequest (System.IAsyncResult asyncResult) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest (System.IAsyncResult result) [0x00000] in <02dcf88f5d2c40b9b769e815214e0dd7>:0
at System.Web.HttpApplication.async_handler_complete_cb (System.IAsyncResult ar) [0x00015] in <eae422b9b12f4162853d52b85a26cb6e>:0
Is it even possible to run a mono-fastcgi-server4 behind multiple subdirectories? I didn't find any example using more than one subdirectory. If not, any other suggestions, how I could solve this problem?
Many thanks in advance!

How to redirect url in nginx permanently?

I want people type or open some url in
https://someweb.com/like-{numberpage}.html
will redirect to
https://someweb.com/like/id
I wrote something like this in the config but it doesn't work.
server {
listen 80;
server_name forum.someweb.com *.forum.someweb.com ;
access_log /var/log/nginx/forum.someweb.access.log main;
error_log /var/log/nginx/forum.someweb.error.log ;
root /var/www/vhosts/someweb.com/public_html/forum ;
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite /urladmin$ $scheme://$host$uri/ permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
location / {
try_files $uri $uri/ /index.php?$args;
rewrite /category-([0-9]+)-([0-9]+).html$ /category.php?id=$1&page=$2 last;
rewrite /index-([0-9]+).html$ /index.php?page=$1 last;
rewrite /like/([0-9]+).html$ /like.php?id=$1 last;
rewrite ^/(.*).html$ /$1.php last;
}
if ($http_host = "forum.someweb.com") {
rewrite ^ https://forum.someweb.com$request_uri permanent;
}
location ~ .*\.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php-fpm.sock;
include fastcgi_params;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME /var/www/vhosts/someweb.com/public_html/forum$fastcgi_script_name;
try_files $uri =404;
}
}
I also restart my nginx server but still.. it doesn't do the redirect.

PRESTASHOP NGINX + REWRITE RULES

I've being searching for a good solution for this combination and after following these:
http://www.phamviet.net/2012/06/03/prestashop-rewrite-url-on-nginx/
Nginx configuration for Prestashop
Prestashop 1.5.6.2 rewrite URLs over nginx install
none of them seemed to work for me at all... so I started experimenting:
After configuring SSL, CloudFlare, etc....
This is what I tried:
server {
listen 80;
server_name mysuperdomain.com www.mysuperdomain.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
# listen 80 deferred; # for Linux
# listen 80 accept_filter=httpready; # for FreeBSD
listen 443;
# The host name to respond to
server_name mysuperdomain.com *.mysuperdomain.com;
# Path for static files
root /sites/mysuperdomain.com/public;
ssl on;
ssl_certificate /etc/nginx/ssl/ssl.pem;
ssl_certificate_key /etc/nginx/ssl/ssl.key;
# Try static files first, then php
index index.html index.htm index.php;
# Specific logs for this vhost
access_log /sites/mysuperdomain.com/log/log-access.log;
error_log /sites/mysuperdomain.com/log/log-error.log error;
#Specify a charset
charset utf-8;
# Redirect needed to "hide" index.php
location / {
rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/$1/$1$2$3.jpg break;
rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/$1/$2/$1$2$3$4.jpg break;
rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/$1/$2/$3/$1$2$3$4$5.jpg break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/$1/$2/$3/$4/$1$2$3$4$5$6.jpg break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg break;
if (-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location /c {
rewrite ^/c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/$1$2$3.jpg break;
rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ /img/$1$2.jpg break;
}
location /images_ie {
rewrite ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$ /js/jquery/plugins/fancybox/images/$1.$2 break;
}
# Don't log robots.txt or favicon.ico files
location ~* ^/(favicon.ico|robots.txt)$ {
access_log off;
log_not_found off;
}
# Custom 404 page
error_page 404 /index.php?controller=404;
location ~* ^.+.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css|mp3|swf|ico|flv|xml) {
access_log off;
expires 30d;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_intercept_errors on;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# Deny access to .htaccess
location ~ /\.ht {
deny all;
}
#PHPMYADMIN
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpeg|jpg|png|css|gif|ico|js|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
# Include the basic h5bp config set
include h5bp/basic.conf;
}
It seems to only work for categories but not for individual products pages and such.
When you hit the main domain or go to the home page, it will download index.php instead of showing the home page.
So a little bit of help would be amazing!
This is working for me perfectly:
server {
fastcgi_read_timeout 180s;
listen 80;
listen 443 ssl;
server_name example.com www.example.com;
ssl on;
ssl_certificate /etc/nginx/ssl/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
error_log /srv/example.com/log/error.log;
root /srv/example.com/html;
location / {
index index.html index.htm index.php;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9010;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/example.com/html$fastcgi_script_name;
fastcgi_param PHP_VALUE max_execution_time=180;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
rewrite "^/c/([0-9]+)(\-[_a-zA-Z0-9-]*)/(.*)\.jpg$" /img/c/$1$2.jpg last;
rewrite "^/c/([_a-zA-Z-]+)/(.*)\.jpg$" /img/c/$1.jpg last;
rewrite "^/([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/(\P{M}\p{M}*)*\.jpg$" /img/p/$1-$2$3.jpg last;
rewrite "^/([0-9]+)\-([0-9]+)/(\P{M}\p{M}*)*\.jpg$" /img/p/$1-$2.jpg last;
rewrite "^/([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$1$2.jpg last;
rewrite "^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$1$2$3.jpg last;
rewrite "^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$1$2$3$4.jpg last;
rewrite "^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
rewrite "^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
rewrite "^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
rewrite "^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
rewrite "^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
rewrite "^/([0-9]+)\-(\P{M}\p{M}*)+\.html(.*)$" /index.php?controller=product&id_product=$1$3 last;
rewrite "^/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=category&id_category=$1$3 last;
rewrite "^/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$" /index.php?controller=product&id_product=$2$4 last;
rewrite "^/([0-9]+)__([a-zA-Z0-9-]*)(.*)$" /index.php?controller=supplier&id_supplier=$1$3 last;
rewrite "^/([0-9]+)_([a-zA-Z0-9-]*)(.*)$" /index.php?controller=manufacturer&id_manufacturer=$1$3 last;
rewrite "^/content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=cms&id_cms=$1$3 last;
rewrite "^/content/category/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=cms&id_cms_category=$1$3 last;
rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last;
rewrite ^/page-not-found$ /index.php?controller=404 last;
rewrite ^/address$ /index.php?controller=address last;
rewrite ^/addresses$ /index.php?controller=addresses last;
rewrite ^/authentication$ /index.php?controller=authentication last;
rewrite ^/best-sales$ /index.php?controller=best-sales last;
rewrite ^/cart$ /index.php?controller=cart last;
rewrite ^/contact-us$ /index.php?controller=contact-form last;
rewrite ^/discount$ /index.php?controller=discount last;
rewrite ^/guest-tracking$ /index.php?controller=guest-tracking last;
rewrite ^/order-history$ /index.php?controller=history last;
rewrite ^/identity$ /index.php?controller=identity last;
rewrite ^/manufacturers$ /index.php?controller=manufacturer last;
rewrite ^/my-account$ /index.php?controller=my-account last;
rewrite ^/new-products$ /index.php?controller=new-products last;
rewrite ^/order$ /index.php?controller=order last;
rewrite ^/order-follow$ /index.php?controller=order-follow last;
rewrite ^/quick-order$ /index.php?controller=order-opc last;
rewrite ^/order-slip$ /index.php?controller=order-slip last;
rewrite ^/password-recovery$ /index.php?controller=password last;
rewrite ^/prices-drop$ /index.php?controller=prices-drop last;
rewrite ^/search$ /index.php?controller=search last;
rewrite ^/sitemap$ /index.php?controller=sitemap last;
rewrite ^/stores$ /index.php?controller=stores last;
rewrite ^/supplier$ /index.php?controller=supplier last;
location ~* \.(gif)$ {
expires 2592000s;
}
location ~* \.(jpeg|jpg)$ {
expires 2592000s;
}
location ~* \.(png)$ {
expires 2592000s;
}
location ~* \.(css)$ {
expires 604800s;
}
location ~* \.(js|jsonp)$ {
expires 604800s;
}
location ~* \.(js)$ {
expires 604800s;
}
location ~* \.(ico)$ {
expires 31536000s;
}
}
That does not work in multilingual sites in 1.6
I found an answer on the prestashop site that works fine but not on multilingual sites.
http://doc.prestashop.com/display/PS16/System+Administrator+Guide#SystemAdministratorGuide-NginxfriendlyURLs
location /PRESTASHOP_FOLDER/ {
index /PRESTASHOP_FOLDER/index.php;
rewrite ^/PRESTASHOP_FOLDER/api/?(.*)$ /PRESTASHOP_FOLDER/webservice/dispatcher.php?url=$1 last;
rewrite ^/PRESTASHOP_FOLDER/([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /PRESTASHOP_FOLDER/img/p/$1/$1$2.jpg last;
rewrite ^/PRESTASHOP_FOLDER/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /PRESTASHOP_FOLDER/img/p/$1/$2/$1$2$3.jpg last;
rewrite ^/PRESTASHOP_FOLDER/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /PRESTASHOP_FOLDER/img/p/$1/$2/$3/$1$2$3$4.jpg last;
rewrite ^/PRESTASHOP_FOLDER/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /PRESTASHOP_FOLDER/img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
rewrite ^/PRESTASHOP_FOLDER/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /PRESTASHOP_FOLDER/img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
rewrite ^/PRESTASHOP_FOLDER/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /PRESTASHOP_FOLDER/img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
rewrite ^/PRESTASHOP_FOLDER/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /PRESTASHOP_FOLDER/img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
rewrite ^/PRESTASHOP_FOLDER/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /PRESTASHOP_FOLDER/img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
rewrite ^/PRESTASHOP_FOLDER/c/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /PRESTASHOP_FOLDER/img/c/$1$2.jpg last;
rewrite ^/PRESTASHOP_FOLDER/c/([a-zA-Z-]+)/[a-zA-Z0-9-]+.jpg$ /PRESTASHOP_FOLDER/img/c/$1.jpg last;
rewrite ^/PRESTASHOP_FOLDER/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /PRESTASHOP_FOLDER/img/c/$1$2.jpg last;
try_files $uri $uri/ /PRESTASHOP_FOLDER/index.php?$args;
}
change /PRESTASHOP_FOLDER/ to / if in root folder
Note: the code in the link above has a typo so use this code instead.
I have generated rewrites using this SQL: (prestashop 1.6.1.6, nginx 1.10.2)
SELECT SQL_CALC_FOUND_ROWS
CONCAT('rewrite ^/',`url_rewrite`,'$ /index.php?controller=', `page`,' last;')
FROM `ps_meta` a
LEFT JOIN `ps_meta_lang` b ON (b.`id_meta` = a.`id_meta` AND b.`id_lang` = 1 AND b.`id_shop` = 1)
WHERE 1 AND a.configurable = 1 AND url_rewrite != ''
GROUP BY a.id_meta
ORDER BY a.`id_meta` ASC
After paste and reload on nginx, friendly urls works good.
you can add also
rewrite ^/products-comparison$ /index.php?controller=products-comparison last;
in the rewrite list ( for Product Comparison Page )

Resources