1

This is my first time posting a question. Kindly let me know if I am missing something that needs to be shared.

I am trying to POST some data into database through my C# APP and API (separately build), but it throws error 404 only for the POST API. All other pages work fine and so does the GET request. The app and API have been deployed on a LINUX machine through NGINX reverse proxy server. Both of them work on HTTP protocol. The feature works for localhost, but not for IP dependent URL.

Here is the content of service file for the app, I do not know what is missing in it. Please take care of the "/" as well where ever it is needed. While performing RnD, I found that the POST request in NGINX gets redirected to GET, I don't know if this will be helpful or not, but felt like sharing.

server {
listen      myIP:6002;
server_name attendancepp;
root        /home/user/net-core/Publish/AttendanceModule/AttendanceApp;
location /AttendanceApp/{
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass      http://myIP:6002/;
            proxy_set_header Accept-Encoding "";
            proxy_cache_bypass      $http_upgrade;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_redirect off;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

The app works on the URL http://myIP:6002/attendance/allPages . All the pages are accessible without any issue. Just the POST part is not working.

Thank you, in advance.

3
  • What request method are you using in c#? There is aproxy property you may need to set.
    – jdweng
    Mar 18, 2021 at 11:20
  • It is just simple [HttpPost("PostEmployees")]. Yes, there is a proxy property that needs to be set, it was supposed to be redirect, set to off. But even that did not help. @jdweng Mar 18, 2021 at 11:45
  • Try setting proxy to null. If proxy is required, the timeout for a proxy is 30 seconds. So check how long it takes to get exception. Also check namespaces from cmd.exe >IPConfig/all. You may need to include the namespace of the proxy.
    – jdweng
    Mar 18, 2021 at 12:18

1 Answer 1

1

working fine after commenting

try_files $uri $uri/ =404
  1. cd /etc/nginx/sites-available/
  2. sudo nano default << nginx
  3. edit file then CTR+X and 'y' for yes
  4. sudo systemctl restart nginx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.