nginx-proxy-manager icon indicating copy to clipboard operation
nginx-proxy-manager copied to clipboard

Creating proxy for nginx-proxy-manager admin interface

Open cboulanger opened this issue 7 years ago • 6 comments

Hi, Awesome piece of software, very useful, thank you very much for publishing it.

I am trying to create a proxy for the admin interface on port ~91~ 81. Here is what I have: Domain name: proxy.mydomain.de (real domain name here) scheme: https Forward host/port: 127.0.0.1:81 SSL certificate: proxy.mydomain.de Force SSL

It shows status "Online", but when I access proxy.mydomain.de, I get a 502 Bad Gateway.

What am I doing wrong?

cboulanger avatar Mar 25 '19 10:03 cboulanger

Can you make sure the service on port 81 is running?

kolbii avatar Mar 25 '19 12:03 kolbii

Yes, it is, I am trying to use it to proxy itself...

cboulanger avatar Mar 25 '19 13:03 cboulanger

My bad. nginx-proxy-manager serves http traffic only. when I switched to http, it worked. Closing.

cboulanger avatar Mar 25 '19 18:03 cboulanger

Can we put the admin interface behind a path? Like: domain.com/npm ? I'm trying it but it won't work. Can't find any info about it.

RosaEinhorn avatar Mar 27 '20 14:03 RosaEinhorn

nope, npm run only un root of URL host

miguelwill avatar Mar 29 '20 01:03 miguelwill

nope, npm run only un root of URL host

This kind of an old issue, but actually it is possible to hide admin panel behind the sub path: https://wiki.sitnikov.eu/doku.php?id=howto:npm#final_npm_configuration Add 2 locations: изображение

From now there are 2 Options. Even if you combine them, you will not harm anything in NPM:

Option 1

And add Advanced rule:

location ~ ^/(css|js|images|login|assets|nginx|users|audit-log|settings) {
  return 307 https://$http_host/npm$request_uri?$args;
}

Replace npm with whatever you need in Custom Location and Advanced config. Now you can control TLS configuration for NPM Admin Panel as for #481, #182

Option 2

UPDATE: Option 2 solutions only, you DO NOT NEED TO ADD API endpoint as above in a screenshot.

In "Custom Location" click on "Options" for /npm/ and add there rewrite content rules, so at the end it looks similar to:

    ### Paste here Rewrite content
    proxy_set_header Accept-Encoding "";
    sub_filter_once off;
    sub_filter_types text/html application/javascript text/css;
    sub_filter '/css' '/npm/css';
    sub_filter '/js/' '/npm/js/';
    sub_filter '"js/"' '"npm/js/"';
    sub_filter '/images' '/npm/images';
    sub_filter '/assets' '/npm/assets';
    sub_filter '/api' '/npm/api';
    sub_filter '/login' '/npm/login';

Also this will be Apache2 Configuration:

Redirect 301 "/npm" "/npm/"
	<Location /npm>
		ProxyPreserveHost On
		ProxyPass http://localhost:81/ retry=0 connectiontimeout=5 timeout=30 keepalive=on
		ProxyPassReverse http://localhost:81/
		RequestHeader set Connection ""
		AddOutputFilterByType INFLATE;SUBSTITUTE text/html application/javascript text/css
		Substitute "s|/css/|/npm/css/|inq"
		Substitute "s|/js/|/npm/js/|inq"
		Substitute "s|\"js/\"|\"npm/js/\"|inq"
		Substitute "s|/images|/npm/images|inq"
		Substitute "s|/assets|/npm/assets|inq"
		Substitute "s|/api|/npm/api|inq"
		Substitute "s|/login|/npm/login|inq"
	</Location>

GAS85 avatar Jan 02 '23 10:01 GAS85