I have a CMS instance that has its Admin panel hard-coded at /admin
(https://example.com/admin
) and it can't be changed by CMS. I thought to try Nginx to carry this task. CMS runs as a Nodejs app and served by proxy_pass
.
location / {
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 REMOTE-HOST $remote_addr;
add_header X-Cache $upstream_cache_status;
proxy_connect_timeout 30s;
proxy_read_timeout 86400s;
proxy_send_timeout 30s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://localhost:8000;
}
Would it be possible to replace https://example.com/admin
with https://example.com/custom
using Nginx only? Any advice is highly welcome as I don't understand where to start here.
P.S. If it matter CMS is Directus.
Upd. I tried to use Nginx reverse proxy + URL rewrite but it didn't help. Here are my attempts:
location /foo {
rewrite /foo/(.*) /admin/$1 break;
proxy_pass localhost:8000;
proxy_redirect off;
proxy_set_header Host $host;
}
gave me /foo
=> /foo/admin/login?redirect=/foo/
location /foo {
rewrite /foo/(.*) /$1 break;
proxy_pass localhost:8000/admin;
proxy_redirect off;
proxy_set_header Host $host;
}
gave me /foo
=> /admin/foo
foo/admin/login?redirect=/foo/
Tried this ``` location /foo { rewrite /foo/(.*) /$1 break; proxy_pass localhost:8000/admin; proxy_redirect off; proxy_set_header Host $host; } ``` And git this URIadmin/foo