NGINX configuration:
I am new to NGINX and I am trying to load balance of our ERP web servers. I have 3 web servers running on port 80, running on websphere, which is a black box for me:
* web01.example.com/path/apphtml
* web02.example.com/path/apphtml
* web03.example.com/path/apphtml
NGINX listens for the virtual url ourerp.example.com and proxies it to the cluster.
Here is my config:
upstream myCluster {
ip_hash;
server web01.example.com:80;
server web02.example.com:80;
server web03.example.com:80;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name ourerp.example.com;
location / {
rewrite ^(.*)$ /path/apphtml break;
proxy_pass http://myCluster;
}
}
When I only use proxy_pass then NGINX download balances but redirects the request to web01.example.com and not web01.example.com/path/apphtml
When I try to add the rewrite url it just rewrites the virtual url and I end up with the ourerp.example.com/path/apphtml file.
Is it possible to rewrite the URL at the top level or add the application path at the top level?
If you are trying to match /
with /path/apphtml/
through a proxy, use:
proxy_pass http://myCluster/path/apphtml/;
See this document for details .
The problem with your operator rewrite
is the missing $1
replacement string at the end. See this document for details , but as I said above, you don't need an operator rewrite
as the operator proxy_pass
is capable of doing the same job anyway.