Webmail problem after setting up Nginx rewrite rules

Nov 9, 2018
1
0
1
28
#1
Hello every-one!
This following instruction is perfect to setup the script on Centos + Vestacp + Nghix: https://support.mfscripts.com/public/kb_view/62/
However, after setting the Nginx rewrite rules by adding the below code into /home/admin/conf/web/nginx.yourdomain.com.conf, the webmail (ip-address/webmail/) does go to 404 error - page not found. I get stuck to access webmail service totally. If remove the part in red color, the webmail works again, but the Nginx rewrite seems not to be configured right. Does any-one have solution for this? Many thanks


# allow for paths ending with forward slashes
rewrite ^/app/(.*)/ /plugins/webdav/site/control/$1 last;
rewrite ^/app/(.*) /plugins/webdav/site/control/$1 last;

# all webdav requests
location /plugins/webdav/site/control/ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
gzip off;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
include fastcgi_params;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
if (!-e $request_filename) { rewrite ^/(.*) /index.php?_page_url=$1 last; }
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
include fastcgi_params;
}

#location / {
if (!-e $request_filename) {
rewrite ^/(.*) /index.php?_page_url=$1 last;
}
#}


location /files/ {
internal;
}

# these locations would be hidden by .htaccess normally
location /core/logs/ {
deny all;
}