Nginx on non root directory problem


Hi all and happy monday!

I am running Senaite LIMS and reverse proxy with nginx. If I put its location on root “/” it works fine, but if I try to put it somewhere else, for example /senaite/, when I access the site it redirects me to /login, rather than senaite/login, and /login does not exist. Is there something in the settings of senaite that I need to change, or should it be done in Nginx? Please excuse me if this is not strictly a Senaite question, I would really appreciate any input.

Below is my nginx site config:

upstream plone {

server {
    listen 80;
    return 301 https://$server_name$request_uri;

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;


    include snippets/self-signed.conf;
    include snippets/ssl-params.conf;
    # include snippets/well-known.conf;

    access_log /var/log/nginx/senaite.access.log;
    error_log /var/log/nginx/senaite.error.log error;

    # Allow Cross-Origin Resource Sharing from our HTTP domain
    add_header "Access-Control-Allow-Credentials" "true";
    add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS";
    add_header "X-Frame-Options" "SAMEORIGIN";

    if ($http_cookie ~* "__ac=([^;]+)(?:;|$)" ) {
        # prevent infinite recursions between http and https
    rewrite ^(.*)(/logged_out)(.*) http://$server_name$1$2$3 redirect;

    location /senaite/ {
        proxy_set_header        Host            $http_host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        rewrite                 ^(.*)$ /VirtualHostBase/$scheme/$host/senaite/VirtualHostRoot/$1 break;
        proxy_pass              http://plone;


Hi, if you look at the rewrite line: the instance you’ve created (senaite)
it determines which one is served (you could have multiple plones on
one server). So if you omitted “senaite” from the line below, your
instance should be available by default at

/VirtualHostBase/$scheme/$host/senaite/VirtualHostRoot/$1 break;

Hope this helps


Yes, it helps 100%! Thanks so much!