# Change cockpit entrypoint url

**URL:** <https://discourse.getcockpit.com/t/change-cockpit-entrypoint-url/500>\
**Category:** Uncategorized\
**Created:** [January 9, 2019, 5:44am UTC](https://discourse.getcockpit.com/t/change-cockpit-entrypoint-url/500 "2019-01-09T05:44:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alessandro](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@alessandro](https://discourse.getcockpit.com/u/alessandro)\
**Post date:** [January 9, 2019, 5:44am UTC](https://discourse.getcockpit.com/t/change-cockpit-entrypoint-url/500/1 "2019-01-09T05:44:10Z")

</div>

Hello,

I’m trying to host cockpit and a node.js server on the same production server. I’m using Nginx to dispatch the access to the two servers based on the requested url.

The idea is that for any url I’d want to forward the traffic to the node.js server exposed on localhost:3000.  
Instead I’d like to forward all the urls starting with ‘cms’ or ‘cockpit’ or any other differentiator to cockpit cms exposed on localhost:8080.

So I’m trying a way to change the cockpit entry point for all its paths. For example:  
localhost:8080/auth/login should be localhost:8080/ **cockpit** /auth/login  
localhost:8080/collections should be localhost:8080/ **cockpit** /collections

in this way I can tell Nginx to forward any traffic to cockpit cms based on if the url starts with cockpit.

Is there a way to do it?  
Thank you

---

<div class="post-metadata">

**Author:** ![alessandro](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@alessandro](https://discourse.getcockpit.com/u/alessandro)\
**Post date:** [January 9, 2019, 4:35pm UTC](https://discourse.getcockpit.com/t/change-cockpit-entrypoint-url/500/2 "2019-01-09T16:35:05Z")

</div>

I’m trying to reverse proxy cockpit cms that run with Docker.

In the official documentation I found ([https://getcockpit.com/documentation/reference/configuration](https://getcockpit.com/documentation/reference/configuration)) that I can change the site url:

```
 # site url (optional) - helpful if you're behind a reverse proxy
'site_url' => 'https://mydomain.com',

```

But it doesn’t really work.

I also tried to edit the define.php file adding some definitions:  
define(‘COCKPIT\_BASE\_URL’, ‘/admin’);  
define(‘COCKPIT\_BASE\_ROUTE’, ‘/admin’);  
define(‘COCKPIT\_DOCS\_ROOT’, “/var/www/html”);

I got to have cockpit forward itself to admin/… but some routes don’t work yet.

Thank you

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [January 12, 2019, 1:51pm UTC](https://discourse.getcockpit.com/t/change-cockpit-entrypoint-url/500/3 "2019-01-12T13:51:29Z")

</div>

@alessandro If you try to understand the paths and constants, have a look here:

> [@Understanding Cockpit - A development guide (work in progress...)](https://discourse.getcockpit.com/t/understanding-cockpit-a-development-guide-work-in-progress/486/2):
>
> Explanation of all paths and constants A few weeks ago, I started to analyze all the paths and constants. For most of them I added a few lines of explanation. I will update this list with the missing parts when I find the time to do it. The example paths are on an [Uberspace](https://manual.uberspace.de/) (CentOS 7) in ~/html/cockpit. Originally, I wrote this text in kramdown and rendered it to HTML. If you want to see the rendered file with a table of contents, have a look here: [source .md](https://github.com/raffaelj/cockpit-scripts/blob/master/development-notes/constants-and-paths.md), [source .html](https://github.com/raffaelj/cockpit-scripts/blob/master/development-notes/constants-and-paths.html) view via [htmlpr…](https://htmlpreview.github.io/?https://github.com/raffaelj/cockpit-scripts/blob/master/development-notes/constants-and-paths.html)

I’m not sure, how to achieve the forwarding, but maybe… it could be easy… Put Cockpit in a subdirectory named `cockpit` → now your url is `localhost:8080/cockpit/auth/login`

Or add a line to the `.htaccess` to rewrite some specific urls.

And you started a second thread

> [@Add prefix to cockpit base url](https://discourse.getcockpit.com/t/add-prefix-to-cockpit-base-url/506):
>
> Hello, I’m using cockpit cms with docker. Cockpit is exposed on my machine on localhost:8080. How to expose cockpit on localhost:8080/[prefix]/ where prefix can be something like ‘cockpit’ or ‘cms’. I’d need to tell cockpit to refer to itself as localhost:8080/[prefix]/ and not just localhost:8080 Thank you

Have a look at index.php of Cockpit:

> <https://github.com/agentejo/cockpit/blob/next/index.php#L17>

> <https://github.com/agentejo/cockpit/blob/next/index.php#L38>

Maybe this might work: define the constant `COCKPIT_ADMIN_ROUTE` in `/config/bootstrap.php` to your needs.

---

<div class="post-metadata">

**Author:** ![pauloamgomes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/pauloamgomes/32/48_2.png) [@pauloamgomes](https://discourse.getcockpit.com/u/pauloamgomes)\
**Post date:** [January 15, 2019, 9:22am UTC](https://discourse.getcockpit.com/t/change-cockpit-entrypoint-url/500/4 "2019-01-15T09:22:15Z")

</div>

Hey @alessandro, think issue is not on cockpit but on nginx configuration, basically what you need is:

[https://domain.abc/cockpit](https://domain.abc/cockpit) =\> [http://localhost:8080](http://localhost:8080)

```auto
(...)
location /cockpit {
    proxy_pass http://127.0.0.1:8080;
    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_set_header X-Forwarded-Proto $scheme;
}
(...)

```

---

<div class="post-metadata">

**Author:** ![Aspanfoot](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@Aspanfoot](https://discourse.getcockpit.com/u/Aspanfoot)\
**Post date:** [January 19, 2020, 8:17pm UTC](https://discourse.getcockpit.com/t/change-cockpit-entrypoint-url/500/5 "2020-01-19T20:17:28Z")

</div>

This worked for me on Docker setup by modifying defines.php, some of assets are still generated with wrong path, because of that settings are infinitely loading.  
\<?php  
define(“COCKPIT\_BASE\_URL”, “/cms”);  
define(“COCKPIT\_BASE\_ROUTE”, “/cms”);  
define(“COCKPIT\_DOCS\_ROOT”, “/var/www/html”);  
define(“COCKPIT\_SITE\_DIR”, “/var/www/html”);  
?\>

I think it would be great to have something like ROOT\_URL or URL\_PREFIX in cockpit config.php file which would add url prefix for all of the routes simplifying reverse proxy setup.

**One of the workarounds would be to use sobdomains on nginx instead of folders.**

# UPDATE

codemirror.js file is getting included in script tag as /cms/assets/…/codemirror.js it causes the issue.

---

<div class="post-metadata">

**Author:** ![Aspanfoot](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@Aspanfoot](https://discourse.getcockpit.com/u/Aspanfoot)\
**Post date:** [January 19, 2020, 8:25pm UTC](https://discourse.getcockpit.com/t/change-cockpit-entrypoint-url/500/6 "2020-01-19T20:25:11Z")

</div>

Did you tried it ? This is not working, it is redirecting to /auth/login on nginx which doesn’t have this location defined. Url prefix should be set from cockpit side.
