A
A
Aimsitheoir2021-10-06 16:10:10
Nginx
Aimsitheoir, 2021-10-06 16:10:10

How to replace url in nginx without changing the request itself?

Hello, I have kvm Raritan, which is able to give direct control of the host via URL (Direct Access via url).
like this https://ip_raritan/dpa.asp?portname=XXX&username=&... .
This link opens a separate window with direct access to the desired host.

And there is a task in which you need to use a link like ip_address/raritan/portname=XXX to redirect the request to raritan by substituting only the port name (portname)

I do it through Nginx, so

location /raritan {
    rewrite ^(/*/.*)/portname=(.*) https://<ip_raritan>/dpa.asp?portname=$2&username=user&password=password last;
    }


All this works, but as you can see, the request contains a password in plain text.

In this regard, the question is whether it is possible to leave the request in Nginx the same, that is, so that the raritan receives the correct request and opens the desired window, but the URL in the browser does not shine with a password. Ideally, should it (URL) remain as ip_address/raritan/portname=XXX ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-10-06
@dodo512

rewrite ^(/*/.*)/portname=(.*) https://<ip_raritan>/dpa.asp?portname=$2&username=user&password=password last;

Just remove https://<ip_raritan>. Then the redirect will be internal and there will be no 302 redirect and the URL will not change in the browser.
rewrite ^(/.*)/portname=(.*) /dpa.asp?portname=$2&username=user&password=password last;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question