Nginx as a reverse proxy for Ajenti

I installed the server block for Ajentiaccording to → http://support.ajenti.org/topic/349870-ajenti-behind-nginx/

location /ajenti {
    rewrite (/ajenti)$ / break;
    rewrite /ajenti/(.*) /$1 break;

    proxy_pass              http://127.0.0.1:8000;
    proxy_redirect /        /ajenti/;
    proxy_set_header        Host             $host;
    proxy_set_header        X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_http_version      1.1;
    proxy_set_header        Upgrade $http_upgrade;
    proxy_set_header        Connection $http_connection;
}

Which returns me to the login, but after logging in, it is Ajentiredirected to "/ ajenti: auth", and not "/ ajenti / ajenti: auth".

For example: Browser → HTTPS → Nginx → HTTP → Ajenti

This also seems to be a problem for "ajenti: static" resources.

See: http://support.ajenti.org/topic/88086-support-ajenti-behind-a-reverse-proxy/

What is the recommended way to handle this in Nginx?

+4
source share
2 answers

EDIT: proxy_set_header Origin http://$host; .

ajenti . 403 . .

server {
    listen 443 ssl;
    server_name ajenti.mymagicalwebsite.com;
    ssl on;

    if ($scheme = http) {
        return 301 https://$server_name$request_uri;
    }

    location / {
        proxy_pass  http://localhost:8000;
        proxy_redirect off;
        proxy_set_header        Host                $host;
        proxy_set_header        X-Real-IP           $remote_addr;
        proxy_set_header        X-Forwarded-For     $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
        proxy_set_header        Upgrade         $http_upgrade;
        proxy_set_header        Connection      "upgrade";
        proxy_read_timeout      36000s;  ## Timeout after 10 hours
    }
}

, .

+4

:

location ~ /ajenti.* , URL- Ajenti.

: .

0

Source: https://habr.com/ru/post/1546509/


All Articles