Score:1

Port redirection is not working as expected in nginx reverse proxy

eg flag

Here is one more issue I am facing. I have portal running on http://test.example.com:8080/AppWise and http://test.example.com/WebAdmin

Now I diverted that portal through Nginx reverse proxy

here is my config

server {
    listen 8080;
    listen 80;
    server_name test.example.com;
    access_log /var/log/nginx/twprod/access.log;
    error_log /var/log/nginx/twprod/error.log;
    include /etc/nginx/applox/feeds/badips.txt;
    location /AppWise/ {
        client_max_body_size 10m;
        client_body_buffer_size 128k;
        proxy_send_timeout 90;
        proxy_read_timeout 90;
        proxy_buffer_size 128k;
        proxy_buffers 4 256k;
        proxy_busy_buffers_size 256k;
        proxy_temp_file_write_size 256k;
        proxy_connect_timeout 30s;
        proxy_pass http://test.example.com:8080;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /WebAdmin/ {
        client_max_body_size 10m;
        client_body_buffer_size 128k;
        proxy_send_timeout 90;
        proxy_read_timeout 90;
        proxy_buffer_size 128k;
        proxy_buffers 4 256k;
        proxy_busy_buffers_size 256k;
        proxy_temp_file_write_size 256k;
        proxy_connect_timeout 30s;
        proxy_pass http://test.example.com:8080;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

The thing is First page open properly and then it asks for username password; this is fine. now after login suddenly I receive 302 and page is diverted to http://test/example.com/Appwise/<...........REST of the URI.....>

10.0.22.99 - - [20/Sep/2021:18:41:05 +0530] "POST /AppWise/servlet/TeamAccess/Login HTTP/1.1" 302 0 "http://test.example.com:8080/AppWise/servlet/TeamAccess/Login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36"
10.0.22.99 - - [20/Sep/2021:18:47:42 +0530] "POST /AppWise/servlet/TeamAccess/Login HTTP/1.1" 302 0 "http://test.example.com:8080/AppWise/servlet/TeamAccess/Login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36"
10.0.22.99 - - [20/Sep/2021:18:51:04 +0530] "POST /AppWise/servlet/TeamAccess/Login HTTP/1.1" 302 0 "http://test.example.com:8080/AppWise/servlet/TeamAccess/Login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36"

I expected for this page to stay at http://test.example.com:8080

in flag
The redirect most probably comes from your backend server. Configure your backend server with the correct base URL.
Blason R avatar
eg flag
Well when I change the entry in my hosts file and point it directly to the server instead of reverse proxy it stays on port 8080. Hence its pretty difficult to convince to server admin that this entry is being pushed from original server.
us flag
When the backend server receives a request to `http://test.example.com`, but it is configured to run at `http://test.example.com:8080`, many backend applications send the redirect to `http://test.example.com`. You can show the fact to the backend server admin by running tcpdump while making a request.
Michael Hampton avatar
cz flag
This redirect absolutely comes from AppWise, not nginx.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.