Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx Deployment | Post Requests #3327

Closed
merlinfuchs opened this issue Oct 6, 2018 · 8 comments
Closed

Nginx Deployment | Post Requests #3327

merlinfuchs opened this issue Oct 6, 2018 · 8 comments
Labels

Comments

@merlinfuchs
Copy link

Long story short

I'm trying to use nginx as a reverse proxy for my aiohttp server. That works fine with get requests, but it seems like nginx overwrites all post requests to get requests.

For example I make a post request to my nginx server and it passes it to the aiohttp server. But the aiohttp server gets a get request instead of post.

I know this is a nginx problem, but I wasn't able to find a solution somewhere else ...

Expected behaviour

Aiohttp should get a post request when making a post request to the nginx server.

Actual behaviour

Aiohttp gets a get request.

Steps to reproduce

Run a aiohttp server on the port 8082 and create a post route.
Configure your nginx server like this:

server {
  listen 80;
  listen 443 ssl;

  ssl_certificate /etc/nginx/ssl/nginx.crt;
  ssl_certificate_key /etc/nginx/ssl/nginx.key;

  server_name api.discord.club;

  underscores_in_headers on;

  location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://localhost:8082;
  }

}

Your environment

Ubuntu 16.04 LTS 64bit,
Nginx 1.10.3,
aiohttp 3.4.4

@aio-libs-bot
Copy link

GitMate.io thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #1392 (Issue with ClientSession.request('POST') method), #872 (proxying request.scheme with nginx), #161 (aiohttp can't send files by POST request correct), #187 (Request.POST preloading), and #1765 (request.post() ignores blank values).

@aio-libs-bot aio-libs-bot added the question StackOverflow label Oct 6, 2018
@MyNameIsCosmo
Copy link

Try the Nginx configuration in the aiohttp docs:
https://docs.aiohttp.org/en/stable/deployment.html#nginx-configuration

@merlinfuchs
Copy link
Author

Still the same problem ...

@merlinfuchs
Copy link
Author

Looks like, the problem doesn't occur if I make the request over https.

@paxswill
Copy link

paxswill commented Nov 7, 2018

If you follow the individual requests, I'd guess you're going to see a 301 or 302 redirect from http to https. Those redirects will commonly change the request method to GET.

@rascalking
Copy link

Pretty sure @paxswill is on to something. Something that's returning a 301/302 should be returning a 307/308 (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections for a discussion of the difference).

@asvetlov
Copy link
Member

asvetlov commented Dec 1, 2018

@rascalking perhaps you right, but hard to confirm without looking on the source code.

Closing the issue, nothing to do here without more info.
I see nothing bad in nginx config, pretty similar configuration works for me perfectly fine.

@asvetlov asvetlov closed this as completed Dec 1, 2018
@lock
Copy link

lock bot commented Dec 1, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Dec 1, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants