|
|
|
|
|
by vince14
426 days ago
|
|
Because projects like these were missing back then, I got creative with nginx and do not need any config changes to serve new projects: server {
listen 80;
server_name ~^(?<sub>\w+)(\.|-)(?<port>\d+).*; # projectx-20201-127-0-0-1.nip.io
root sites/$sub/public_html;
try_files $uri @backend;
location @backend {
proxy_pass http://127.0.0.1:$port;
access_log logs/$sub.access;
}
}
Configuration is done via the domain name like projectx-20205-127-0-0-1.nip.io which specifies the directory and port.All you need to do is create a junction (mklink /J domain folder_path). This maps the domain to a folder. |
|
I think proxy_pass will forward traffic even when the root and try_files directives fail because the junction/symlink don't exist? And "listen 80" binds on all interfaces doesn't it, not just on localhost?
Is this clever? Sure. But this is also the thing you forget about in 6 months and then when you install any app that has a localhost web management interface (like syncthing) you've accidentally exposed your entire computer including your ssh keys to the internet.