# Install on nginx (EDIT: updated with some specifics)

**URL:** <https://discourse.getcockpit.com/t/install-on-nginx-edit-updated-with-some-specifics/1012>\
**Category:** Support\
**Created:** [September 11, 2019, 4:54pm UTC](https://discourse.getcockpit.com/t/install-on-nginx-edit-updated-with-some-specifics/1012 "2019-09-11T16:54:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![randohinn](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/randohinn/32/419_2.png) [@randohinn](https://discourse.getcockpit.com/u/randohinn)\
**Post date:** [September 11, 2019, 4:54pm UTC](https://discourse.getcockpit.com/t/install-on-nginx-edit-updated-with-some-specifics/1012/1 "2019-09-11T16:54:10Z")

</div>

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` 😕

`admin/auth/login` gets captured by my main site

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [September 11, 2019, 11:19pm UTC](https://discourse.getcockpit.com/t/install-on-nginx-edit-updated-with-some-specifics/1012/2 "2019-09-11T23:19:37Z")

</div>

example config (not tested)

```auto
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;
    }
}

```
