mod-rewriteproxyreverse-proxynginx-locationseafile-server

nginx proxy_pass and rewrite for seafile proxy


I'm running a seafile vm (private network) behind a Plesk vm (public).

Right now I'm using apache as proxy but was wondering how to get this setup running with nginx only.

This works:

RewriteEngine On

ProxyPass /seafhttp http://192.168.10.102:8082
ProxyPassReverse /seafhttp http://192.168.10.102:8082
RewriteRule ^/seafhttp - [QSA,L]

RewriteRule ^/(.*) http://192.168.10.102:8000/$1 [P]
ProxyPassReverse  / http://192.168.10.102:8000/

This doesn't:

location /seafhttp {
    rewrite ^/seafhttp(.*)$ $1 break;
    proxy_pass http://192.168.10.102:8082;
    client_max_body_size 0;
    proxy_connect_timeout  36000s;
    proxy_read_timeout  36000s;
    proxy_send_timeout  36000s;
    send_timeout  36000s;
}

location ~ / {
    proxy_pass http://192.168.10.101:8065;
}

But this again does work:

RewriteEngine On

RewriteRule ^/(.*) http://192.168.10.102:8000/$1 [P]
ProxyPassReverse  / http://192.168.10.102:8000/

+

location /seafhttp {
    rewrite ^/seafhttp(.*)$ $1 break;
    proxy_pass http://192.168.10.102:8082;
    client_max_body_size 0;
    proxy_connect_timeout  36000s;
    proxy_read_timeout  36000s;
    proxy_send_timeout  36000s;
    send_timeout  36000s;
}

What am I missing here?

Thanks Max


Solution

  • Fix below:

    location ^~ /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://192.168.10.102:8082;
        client_max_body_size 0;
        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
        proxy_send_timeout  36000s;
        send_timeout  36000s;
    }
    
    location ~ / {
        proxy_pass http://192.168.10.102:8000;
    }