NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
20.96k stars 2.42k forks source link

How to add a static website for root location? #1913

Open jearton opened 2 years ago

jearton commented 2 years ago

Is your feature request related to a problem? Please describe.

No.

Describe the solution you'd like

  1. Add root location mapping to a root directory which has an index.html file.
  2. Add custom location to reverse proxy.

Describe alternatives you've considered

Use native nginx.

Additional context

jearton commented 2 years ago

I found a solution through reading the source code. Just add the root location directive block in the proxy advanced configuration, then the root location of reverse proxy will not be generated. The relevant source code is as follows:

https://github.com/NginxProxyManager/nginx-proxy-manager/blob/develop/backend/internal/nginx.js#L220 image

https://github.com/NginxProxyManager/nginx-proxy-manager/blob/develop/backend/templates/proxy_host.conf#L29 image

florianchevallier commented 1 year ago

To complete the response here :

you can create a dummy nginx conf like this :

image

And then add an advanced configuration like this

root                   /downloads;
location / {
  autoindex             on;
  autoindex_exact_size  on;
  autoindex_format      html;
  autoindex_localtime   on;
}

⚠️ the path has to be mounted in you docker / docker-compose file.

ymjlabMax commented 4 months ago

I have a question.

What does http://localhost:11111/ mean?

root /deploy; location / { autoindex on; autoindex_exact_size on; autoindex_format html; autoindex_localtime on; }

Should the root location here be aligned with the docker-compose file location?

I'm asking because I'm currently encountering a 404 not-found error.

dyingway commented 3 months ago

I have a question.

What does http://localhost:11111/ mean?

root /deploy; location / { autoindex on; autoindex_exact_size on; autoindex_format html; autoindex_localtime on; }

Should the root location here be aligned with the docker-compose file location?

I'm asking because I'm currently encountering a 404 not-found error.

the guy had mention,⚠️ the path has to be mounted in you docker / docker-compose file.

i think you might don't know how to do,so i give a example,if your html files location in /srv then ,you should edit your docker-compose.yml like this:

    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
      - /srv:/srv

then 404 will disappear