Score:1

Nginx converts POST Request to GET request while proxy_pass

es flag

I am having 3 Server: A, B, C. Details are:

  1. Server A: NGINX Server, URL: https://test1.example.com
  2. Server B: NGINX Server hosting NodeJS Web Application, URL: http://test2.example.com
  3. Server C: Apache2 Server hosting Django Web Application, URL: http://test3.example.com

Server A(NGINX Server) is front facing public facing server acting as load balancer using proxy_pass. Server B(NGINX Server) is having a form and submitting it through POST request to Server C(UWSGI Django Server using Apache2). The request is from Server B with url: https://test1.example.com/register to Server C but Server A is converting it to GET request.

So I am getting 2 request log one with POST and other with GET with same path "/register"

The setup is depicted in figure (Diagram is at the end of the post).

The configuration is as follows:

  1. Server A:

    server {
    
       listen 443 ssl http2;
       listen [::]:443 ssl http2;
       server_name test1.example.com;
    
        ssl_certificate /etc/ssl/test1/test1.example.com.crt;
        ssl_certificate_key /etc/ssl/test1/test1.example.com.key;
    
       # Proxy/Loadbalancer configuration`
    
       # Testing the request`
    
            location / {
              proxy_pass http://test2.example.com;
            }
    
            location /register/{
                    proxy_pass http://test3.example.com;
            }
    }
    
  2. Server B:

    server {
    
        listen 80 default_server;
    
        listen [::]:80 default_server;
    
        root /var/www/html;
    
        # Add index.php to the list if you are using PHP
        index index.html index.htm;
    
        server_name test2.example.com;
    
        location / {
                #try_files $uri $uri/ =404;
                 try_files $uri $uri/ /index.html;
        }
    
        access_log /var/log/nginx/access.log;
        error_log  /var/log/nginx/error.log;
    

    }

  3. Server C:

    <VirtualHost *:80>
    ServerName  test3.example.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/test
    
    Alias /static/  /var/www/test/webapp/static/
    Alias /media/  /var/www/test/media/
    
    WSGIScriptAlias /   /var/www/test/webapp/wsgi.py
    WSGIDaemonProcess   cdac.in  python-path=/var/www/test \
        python-home=/var/www/test/venv  processes=5   threads=8
    WSGIProcessGroup cdac.in
    <Directory /var/www/test/webapp/>
        Options -Indexes
        Order deny,allow
        Allow from all
        Require all granted
    </Directory>
    
    LogLevel info
    
    # PROJECT_NAME is used to separate the log files of this application
    ErrorLog    /var/log/apache2/error.log
    CustomLog   /var/log/apache2/access.log combined
    

Where am I going wrong.

Setup Diagram

djdomi avatar
za flag
after searching a bit, i found this https://serverfault.com/questions/312111/how-do-i-get-nginx-to-forward-http-post-requests-via-rewrite maybe it helps you
Amarjeet Sharma avatar
es flag
@djdomi Tried not working
fr flag
did you fix it?
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.