Ajenti behind NGINX

All Ajenti URLs are absolute and start with /ajenti:, which makes it easy to reverse-proxy it with NGINX:
server {
    client_max_body_size 20m;

    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 Origin http://$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;
    }
}

You can further improve performance by making Ajenti listen on a UNIX socket. For that, set Host in Configure > General to something like /var/run/ajenti.sock, and replace <code>proxy_pass URL with http://unix:/var/run/ajenti.sock

This article was helpful for 36 people. Czy artykuł był pomocny?