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

Host static content?

Open ScottBeeson opened this issue 2 years ago • 13 comments

Is your feature request related to a problem? Please describe. Kind of. It's missing functionality, in my opinion.

Describe the solution you'd like I might just be missing this, but with Nginx you can simply use it as a webserver. Not a proxy, redirect, stream, etc. I don't see how to do that in NPM. I need to be able to specify a domain (say downloads.mycompany.com) and a folder, either local or UNC to serve. Then if I visit downloads.mycompany.com/file1.txt I would be served the file.

Describe alternatives you've considered Manually adding the following to the config

server {
	listen		  	80;
	server_name   		downloads.mycompany.com;
	root          		c:/webroot/;
	location / {
		alias     		C:/webroot/downloads/;
		autoindex 	on;
	}

Additional context

ScottBeeson avatar Mar 09 '22 14:03 ScottBeeson

Good idea

ririko5834 avatar Mar 11 '22 09:03 ririko5834

It's a magnificent idea yeah but not the goal of this project which is having the proxy features in mind

timmy1420 avatar Mar 11 '22 15:03 timmy1420

#1913

jearton avatar Mar 12 '22 08:03 jearton

It's a magnificent idea yeah but not the goal of this project which is having the proxy features in mind

Makes sense, but if I'm already using NPM for proxying, seems silly to set up another instance of Nginx or Apache just to serve a couple static files when this could easily have the capability. Seems it would be very similar to the "404 Hosts" feature (although I don't even understand the purpose of this feature)

ScottBeeson avatar Mar 14 '22 17:03 ScottBeeson

@ScottBeeson I also don't understand the purpose of the "404 Hosts" feature.

jearton avatar Mar 18 '22 04:03 jearton

Makes sense, but if I'm already using NPM for proxying, seems silly to set up another instance of Nginx or Apache just to serve a couple static files when this could easily have the capability. Seems it would be very similar to the "404 Hosts" feature (although I don't even understand the purpose of this feature)

It's not possible to have nginx on vps and nginx in docker container using nginx proxy manager (you will get error failed to bind to 80 and 443 ports), I would appreciate if there will be option to write configs and restart nginx that is on the vps (not nginx in docker) https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1923

Also I would appreciate the option to host static site, that you provide path where it is located on the server (or in S3 storage, git repo and other) and it will serve static content, there should be also PHP version picker and so.

ririko5834 avatar Mar 18 '22 13:03 ririko5834

It's not possible to have nginx on vps and nginx in docker container using nginx proxy manager (you will get error failed to bind to 80 and 443 ports), I would appreciate if there will be option to write configs and restart nginx that is on the vps (not nginx in docker) #1923

Don't run nginx in the host. When running docker you are supposed to run everything in containers, not on the host (afaik you can it just makes it a lot harder). If you also need PHP/database etc there are tons of docker lamp/lemp stacks available in the hub. I have build my own here which also includes nginx-proxy-manager

Also I would appreciate the option to host static site, that you provide path where it is located on the server (or in S3 storage, git repo and other) and it will serve static content, there should be also PHP version picker and so.

That's not the purpose of a proxy.

rallisf1 avatar Mar 23 '22 12:03 rallisf1

@ScottBeeson There is a solution to this issue: #1913

jearton avatar Mar 26 '22 15:03 jearton

I wish this feature is available. This feature will help when some of the domains are static websites, the same nginx can serve instead of proxying to another server. Also through admin panel, user can create the domain and folder mapping. A docker volume can be used to host the static files for the domain.

msnisha avatar Jan 26 '24 14:01 msnisha

you can do that, including mysql and php using docker:

example:

version: "3"
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    container_name: npm-app
    restart: unless-stopped
    ports:
      - '80:80'
      - '443:443'
      - '81:81'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
      # mount your folder here
      - /var/www:/var/www
    depends_on:
      - db
      - php

  php:
    image: php:8-fpm
    container_name: npm-php
    restart: always
    volumes:
      - /var/www:/var/www

  db:
    image: 'jc21/mariadb-aria:latest'
    container_name: npm-db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./data/mysql:/var/lib/mysql

Custom NGINX Config for the Proxy Host on port 80

root /var/www/html;

location / {
  try_files $uri $uri/ /index.php?$args;
  index index.php index.html index.htm;
}


location ~ \.php$ {
    if (!-f $request_filename) { return 404; }
    fastcgi_pass php:9000;

    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}

the mount of the volume is important in the "npm-app" container.

Vanillabacke avatar Feb 18 '24 20:02 Vanillabacke