NGINX rewrite rules problem

tophi

New Member
Hi,
I have purchased the mailwiz a few days ago, but still unable to even log in, because of the redirect issues.
I read all the related information - forum and the https://kb.mailwizz.com/articles/nginx-server-basic-configuration-for-mailwizz/ page.

I am running the mailwiz in a sub folder under protected area to get feel how it works.
So far it doesn't...
Here is my config file, I have tested different settings in the /mail location without success.



Code:
server {
#            listen       8080;

    listen            1.2.3.4;
    server_name       1.2.3.4;
    error_log /var/log/nginx/http.error warn;
    #charset koi8-r;

    access_log  /var/log/nginx/http.access  main;

    # Load configuration files for the default server block.
    #include /etc/nginx/default.d/*.conf;

    location / {
        root   /home/http;
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args;

location / {
    allow 1.2.3.4;
    deny  all;
}

location /mail {
#      rewrite ^/mail/(mail/(tag|category|20??)/.*)+$ /mail/index.php?$1;
#      try_files $uri $uri/ /mail/*?$args;

         if (!-e $request_filename){
             rewrite ^(/)?api/.*$ /mail/api/index.php?$args;
         }
         if (!-e $request_filename){
             rewrite ^(/)?customer/.*$ /mail/customer/index.php?$args;
         }
         if (!-e $request_filename){
             rewrite ^(/)?backend/.*$ /mail/backend/index.php?$args;
         }
         if (!-e $request_filename){
             rewrite ^(.*)$ /mail/index.php?$args;
         }
         index  index.html index.htm index.php;
#      try_files $uri $uri/ /*?$args;

}




    }



    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /home/http;
#        fastcgi_pass   127.0.0.1:9000;
       # fastcgi_pass   unix:/var/opt/remi/php72/run/php-fpm/php-fpm.pid;
        fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/http$fastcgi_script_name;
        include        fastcgi_params;
    }








}
 
I am not sure but i guess the mail location should have a trailing space, like:
Code:
location /mail/ {
         if (!-e $request_filename){
             rewrite ^(/)?api/.*$ /mail/api/index.php?$args;
         }
         if (!-e $request_filename){
             rewrite ^(/)?customer/.*$ /mail/customer/index.php?$args;
         }
         if (!-e $request_filename){
             rewrite ^(/)?backend/.*$ /mail/backend/index.php?$args;
         }
         if (!-e $request_filename){
             rewrite ^(.*)$ /mail/index.php?$args;
         }
         index  index.html index.htm index.php;

}
Anyway, this is more of a try and fail type of things, if you cannot get it going, we can try this on a VPS with same location and when we make it work, tell you what worked, so just let us know.
 
Back
Top