Welcome! Log In Create A New Profile


Transparently relocate / move services

Posted by lalebarde 
Transparently relocate / move services
January 26, 2022 05:28AM

There are many posts of people having services or apps on different domains or ports and who wish to clean the URI by the use of subdirectories (subfolders), or the opposite:

* [Move a service in a URI subfolder?](https://forum.nginx.org/read.php?11,293439)
* [Wordpress url prefix nginx Subdomain / Subfolder](https://forum.nginx.org/read.php?3,292256,292256#msg-292256)
* [I want nginx subdirectory to point to differnt containers](https://forum.nginx.org/read.php?11,293244,293244#msg-293244)
* [ProxyPass domain to subdirectory](https://forum.nginx.org/read.php?11,291266,291266#msg-291266)
* [Trying to reconfigure nginx to put an existing service in a subfolder](https://stackoverflow.com/questions/70827539/trying-to-reconfigure-nginx-to-put-an-existing-service-in-a-subfolder)
* [Configure Nginx with proxy_pass](https://stackoverflow.com/questions/12847771/configure-nginx-with-proxy-pass)
* [nginx subdirectory as root along with other folders](https://serverfault.com/questions/827375/nginx-subdirectory-as-root-along-with-other-folders/827383)
* [nginx sub directory wildcard rewrite ](https://serverfault.com/questions/787291/nginx-sub-directory-wildcard-rewrite/787599#787599)
* [Nginx with multiple sites in subfolders](https://stackoverflow.com/questions/17664519/nginx-with-multiple-sites-in-subfolders)
* etc

Solutions leads to use locate regexp along with 'try_files' directives, firewall configuration, services modifications. Some people looks to remain with no solution due to the lack of expertise and/or answers.

It would be nice to have an easy feature to, starting from an existing service, without the need to modify it whatsoever, whether it is static, WSGI, or something else, that permits to publish another URI:port.

* From mydomain.com to mydomain.com/service1 or to mydomain.com:8888
* From service1.mydomain.com to mydomain.com/service1
* etc

So, FROM could be either mydomain.com, service1.mydomain.com, mydomain.com/service1, same with specific port : mydomain.com:9999, service1.mydomain.com:9999, mydomain.com/service1:9999

and TO could be any of the same list : mydomain.com, service1.mydomain.com, mydomain.com/service1, mydomain.com:8888, service1.mydomain.com:8888, mydomain.com/service1:8888

Example of pseudo code :

____server {
________listen 80;
________location / {
____________include proxy_params;
____________proxy_pass http://unix:/var/run/service1flask.sock;

____server {
________listen 80;
________location from /service1 to / {
____________include proxy_params;
____________proxy_pass http://unix:/var/run/service1flask.sock;

So here, nginx in the locate block would substitute "/service1" in the URI by "" from client to server, and the opposite would substitute "" to "/service1" in the answer with the help of the URI context.

Advantages :
* Save resources : systems, human design and maintenance workload
* Don't modify the service or app
* Quick and straightforward

Edited 1 time(s). Last edit at 01/26/2022 05:33AM by lalebarde.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 79
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready