vercel / micro

Asynchronous HTTP microservices
MIT License
10.59k stars 459 forks source link

Nginx reverse proxy + docker. Request methods do not match #385

Closed mishushakov closed 5 years ago

mishushakov commented 5 years ago

Hey, im running into issue here. I have created a micro-service, built it using docker and provisioned it with docker compose (together with Nginx reverse proxy on the same overlay network). For some unknown reason, when running behind a proxy, the req.method in the javascript does not match the actual request method. Here is a screenshot of what I'm talking about:

ilm-o7dhbw8

The first terminal is displaying micro-dev output, which i attached to the container (running on port 80) The second terminal displays the nginx logs

In the background you can see the Postman client with "PUT" request method selected. But for some reason micro sees "GET" there :(

Here is my Nginx configuration file:

events {

}

http {
    server {
        listen 80 default_server;
        listen [::]:80 default_server;

        server_name _;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_redirect off;

        location /auth/ {
            proxy_pass http://auth;
        }
    }
}

However, when i have exposed the auth service to my host machine, I could do any of request methods, that my app supports. I will later try to run some other proxy software and see if it works.

Thank you.

mishushakov commented 5 years ago

Moved To Kubernetes & Traefik. Problem solved. Thank you again @zeit for creating the library

Best wishes.

huxulm commented 5 years ago

Moved To Kubernetes & Traefik. Problem solved. Thank you again @zeit for creating the library

Best wishes.

Recently I am looking into Micro, I also went into this problem. Thanks! I will try it.