Closed callebridholm closed 3 years ago
Yep so you're requesting a Static site configuration and NPM doesn't support that yet. I'll keep this in mind when planning for the next major version.
Yep so you're requesting a Static site configuration and NPM doesn't support that yet. I'll keep this in mind when planning for the next major version.
Yes for example I want to replace a vhost in Apache2 pointing to /var/www/mysite/ with this proxy if possible to not need to run two web servers at the same machine.
i did this a while ago, didnt know it should be impossible so nothing stopped me.
i added an environment path: /websites : /mnt/user/appdata/NginxProxyManager/websites
i set the details to 1.1.1.1:1 because i had to fill in everything.
and set the advance thing to
location / { root /websites; }
and then you get set it to a subdomain (websites for example), and just use it like websites.XXXXXX.com/index.html and the html page will show up
@jc21 I would love to see this feature built-in. I will help if you have any pointers on how you would like to see this done.
@ikomhoog This worked for me. Thanks for the workaround!
complete @ikomhoog answer, thanks to @ikomhoog . :+1:
/opt/websites:/mnt/user/appdata/NginxProxyManager/websites
root /mnt/user/appdata/NginxProxyManager/websites;
index index.html;
location / {
try_files $uri /index.html /index.html;
}
docker-compose up -d
@FaRzad-845 - Thanks for your input, I've been able to get it running however the CSS/JS on the site fails to load.
If I were to load the .html file, then everything is loaded without any problems.
However, when going to the site's URL, the only thing I see is the html site. Are there additional steps to getting the CSS and JS working?
@Jacob-Lasky i use above snippet for react app and everything is okay. can you give more details on what exactly you do ?
complete @ikomhoog answer, thanks to @ikomhoog . 👍
- add volume like
/opt/websites:/mnt/user/appdata/NginxProxyManager/websites
- set the details to 1.1.1.1:1 or everything you like.
- then in advance section add these lines:
root /mnt/user/appdata/NginxProxyManager/websites; index index.html; location / { try_files $uri /index.html /index.html; }
- don't forget to run
docker-compose up -d
- you can use it in a subdomain or main domain.
- have fun.
Working for me, and how to apply the SSL certificate?
@nandhakumargdr for me the SSL certificate just works like for a normal proxy, via the SSL tab of the nginx-proxy-manager "New/Edit Proxy Host" screen.
as an update to the earlier config, I now use a shorter method(still the same steps as before, just a shorter version under the advance tab): this redirects mydomain.com to portfolio.mydomain.com but if I use mydomain.com/index.html it will return /websites/index.html
location = / {
return 301 https://portfolio.mydomain.com;
}
location / {
root /websites;
}
This is also useful if you want to download a file since it will just return the file instead of only returning index.html.
So Im trying to migrate my SWAG setup over to this tool, its much easier to start up a proxy. I'm having a hard time following exactly what goes where to get this working as a simple webserver for my static webpages I'm hosting.
How do I fill out the entire Details tab? How do I fill out the entire Custom location tab and what is it signifying?
as an update to the earlier config, I now use a shorter method(still the same steps as before, just a shorter version under the advance tab): this redirects mydomain.com to portfolio.mydomain.com but if I use mydomain.com/index.html it will return /websites/index.html
location = / { return 301 https://portfolio.mydomain.com; } location / { root /websites; }
This is also useful if you want to download a file since it will just return the file instead of only returning index.html.
How do I fill out the entire Details tab? How do I fill out the entire Custom location tab and what is it signifying?
In the details tab you just fill in a subdomain, random ip and random port. This is because it has to be filled in in order to save the proxy.
I don't actually know the custom location tab, i haven't tried it, i always leave it blank. I fill in the advanced tab with nginx config code.
I cant get it to work, especially the advance section underlines some parts in red and doesnt allow me to save it. Im a rook, any more pointers you could give me? Thanks in advance My volumes: volumes:
these are my volumes:
-v '/mnt/user/appdata/NginxProxyManager/data':'/data':'rw'
-v '/mnt/user/appdata/NginxProxyManager/letsencrypt':'/etc/letsencrypt':'rw'
-v '/mnt/user/Websites/':'/websites':'rw'
I made Websites share for this. I gave nginx a new path named /websites Whereas you have given it '/mnt/user/appdata/NginxProxyManager/websites' Now if you want to refer to that folder you have to use '/mnt/user/appdata/NginxProxyManager/websites' where I can use /websites.
So it might be better to just change it to the same for simplicity(not an expert so there might be something wrong with this)
I dont get red lines when typing in the advance section and even when putting in garbage text i can still save it. It wont work ofcourse and shows the proxy as "offline" with a red dot instead of a green one. But that shouldnt be the issue
Did you follow the earlier steps of filling in the first tab "details" where it asks the domain names, IP and Port? just fill in a random IP/Port just because you cannot save if you miss these.
/websites : /mnt/user/appdata/NginxProxyManager/websites
1.1.1.1:1
for this example.location / {
root /websites;
}
test.txt
into the directory you assigned at step 1, this is /mnt/user/appdata/NginxProxyManager/websites
in my example.I hope this helps
You are a gentleman! I owe you a biertje. Im new to this topic and you taking the time to break it down into simple steps helps me tremendously.
An interesting tidbit I have found, in case someone else has the same issue with SPAs: I tried to make the above work with a single page app (Blazor, however applies for ReactJs as well), Nginx's route always overwrote the router of the apps, therefore I kept receiving an error if I didnt start at /index.html. However, the solution is to force all requests through the index page, hence forcing them to go through the js router of the framework. You need to add: "try_files $uri $uri/ /index.html" . I could not add this in the advanced tab for some reason, it was underlined and wouldn't let me save it, however if you manually add the line into the datavolume/nginx/proxy_host/1.conf, it works like magic! No idea why it wont let me add this line in the GUI though...my file now looks like (not sure if this will persist, however it should as long as the volume is kept):
server { set $forward_scheme http; set $server "1.1.1.1"; set $port 80; listen 80; listen [::]:80; server_name localhost; access_log /data/logs/proxy_host-1.log proxy; location / { root /websites; index index.html index.htm; try_files $uri $uri/ /index.html; }
1. add volume like `/opt/websites:/mnt/user/appdata/NginxProxyManager/websites` 2. set the details to 1.1.1.1:1 or everything you like. 3. then in advance section add these lines:
root /mnt/user/appdata/NginxProxyManager/websites; index index.html; location / { try_files $uri /index.html /index.html; }
1. don't forget to run `docker-compose up -d` 2. you can use it in a subdomain or main domain. 3. have fun.
@FaRzad-845 - apologies for such a huge delay. Your instructions here worked great for me, with one change.
I needed to make sure that "cache assets" was turned off. Otherwise, I cannot load the CSS for some reason.
Thanks for this snipped!
complete @ikomhoog answer, thanks to @ikomhoog . 👍
- add volume like
/opt/websites:/mnt/user/appdata/NginxProxyManager/websites
- set the details to 1.1.1.1:1 or everything you like.
- then in advance section add these lines:
root /mnt/user/appdata/NginxProxyManager/websites; index index.html; location / { try_files $uri /index.html /index.html; }
- don't forget to run
docker-compose up -d
- you can use it in a subdomain or main domain.
- have fun.
Thanks! this works although I'm unable to get the force ssl option to work when doing so.
EDIT: I was able to get force ssl to work by changing some stuff:
if ($scheme = http) {
return 301 https://$server$request_uri;
}
root /mnt/user/appdata/NginxProxyManager/websites;
index index.html;
location / {
try_files $uri /index.html /index.html;
}
This seems to be working so far.
This is how i sorted this out, might not be the best option:
Installed & ran apache2 web server to listen to port 8081 instead of port 80, Then went to NPM and made a reverse proxy for xyz.domain.com to point to IP:8081. It works well for a single static site!
Can someone help if i want to do a virtual host thing? i.e. multiple websites to be opened up via single reverse proxy. I have not understood the solution given over here, would be grateful if someone can help with screenshots!
i tryed everything still getting 403 without try_files $uri /index.html /index.html;
with this line i'm getting 500 any help pls
@farzad-845 @jc21
@Casal0x
The minimum lines I needed in the advanced section are the following:
location / {
root /path/to/website/folder;
}
As long as you have an index.html within the folder you're pointing to then you should be good.
I use the NginxProxyManager in UnRAID through docker and these are my settings
Just make sure that your container can see the folder you're using, and I haven't had problems with removing try_files
Let me know if this works.
complete @ikomhoog answer, thanks to @ikomhoog . 👍
- add volume like
/opt/websites:/mnt/user/appdata/NginxProxyManager/websites
- set the details to 1.1.1.1:1 or everything you like.
- then in advance section add these lines:
root /mnt/user/appdata/NginxProxyManager/websites; index index.html; location / { try_files $uri /index.html /index.html; }
- don't forget to run
docker-compose up -d
- you can use it in a subdomain or main domain.
- have fun.
Working for me, and how to apply the SSL certificate?
This worked 99% perfectly for me too. Thank you. I opted for "nginx-static" instead of 1.1.1.1, just so it is a bit more self descriptive. But it still works. Now my problem is when I go to sub.site.com/folder/ it doesn't load the index.htm from the folder. It works at "/", just not at "/folder/". Any ideas there? I've tried a few things but they all don't work and I can't figure it out from the NGINX documentation. --thanks for the easy solution
Hi, I recently used apache2 at my Debian device as web server. Then I found this thing that helped my to publish several thing on other machines in my local network with SSL to the web. To still be able to publish things at my local machine I earlier use apache2 directly for I now use nginx-proxy-manager and point to localhost:8080 (I change port for apache2). is it possible to just replace apache2 with nginx-proxy-manager directly as the only webserver? I have problem with one application hosted on the same machine as nginx-proxy-manager when it act as proxy for apache2. I found that you can specify some local folders but still you need to point to some ip address somehow.