nginx + apache webapps regex conflict

simplificare

Verified User
Joined
Jul 10, 2019
Messages
52
I've created a custom webapp that points any domain.tld/email to /var/www/html/email using the custom webapps.list file in the custombuild/custom folder however a client recently pointed out that the page on their website located at /email-marketing was loading a 404 nginx page. While the /email page would still load.

I believe this comes down to how the regex is matching the URL and am not 100% sure how to fix it.

As a test, I created https://www.simplificare.net/email-test, where you see the 404. While https://www.simplificare.net/email functions properly.

Does anyone have any ideas to get the regex to match only on email for the webapp and still allow urls on websites that contain more than just 'email'?

Thanks!
Michael
 
Hello Michael,

This is due to how DirectAdmin manages locations:

Code:
        location ^~ /email {
                root /var/www/html/;
                index index.php index.html index.htm;

As you can see there is not a closing slash in the location line. So you might report it to @smtalk Not too sure, whether can they offer another solution though.

And in order to bypass it you will need to add a custom location in nginx:

1. connect DA as admin
2. go to "Customize configuration" page
3. find your domain
4. choose "nginx"
5. Customize configuration
6. Choose "custom3"
7. add code:

Code:
location /email-test
{
        # access_log off;
        proxy_buffering on;
        proxy_pass http://127.0.0.1:8080/rainloop-test;
        proxy_set_header X-Client-IP      $remote_addr;
        proxy_set_header X-Accel-Internal /nginx_static_files;
        proxy_set_header Host             $host;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_hide_header Upgrade;

}

replace 127.0.0.1 with your server's IP, which is used on "location /".

Save changes and test it.
 
Back
Top