Install on nginx (EDIT: updated with some specifics)

What’s the correct server config to use for hosting cockpit under a separate location ? Say, /admin. The best I’ve gotten has been Primary script unknown errors from fastcgi.

Having some trouble getting it running if I want to have my site code in root/public and cockpit in root/admin :confused:

admin/auth/login gets captured by my main site

example config (not tested)

server {

    listen 80;
    server_name localhost;

    root /usr/share/nginx/html;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    # enable gzip compression
    gzip on;
    gzip_min_length  1100;
    gzip_buffers  4 32k;
    gzip_types    text/plain application/x-javascript text/xml text/css image/svg+xml;
    gzip_vary on;
    # end gzip configuration
    
    # enable browser caching
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff)$ {
        expires 1y;
        log_not_found off;
    }

    # deny direct access to files
    location ~ .sqlite$ {
        deny all;
    }
    location ~ .yaml$ {
        deny all;
    }
    location ~ /\.git {
      deny all;
    }
    
    location /admin {
        try_files $uri $uri/ /admin/index.php$is_args$args;
        index index.php index.html index.htm;
    }

    location ~ \.php$ {
	try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
	fastcgi_pass unix:/var/run/php7-fpm.sock;
	fastcgi_index index.php;
	include fastcgi_params;
    }
}