Reverse proxy unexpectedly transforming POST requests into GET requests

1. The problem I’m having:

Essentially I’ve been using this template: GitHub - TomDoesTech/caddy-nodejs-docker-tutorial in an attempt to to try deploy a golang application with automatic tls. It all works fine for the most part and I can call GET endpoints on my app through the https url however when I try and call a POST endpoint the golang application sees that it insteads gets a GET request instead. This is not the case when testing on localhost. I’m new to caddy and this kind of technology so I’m assuming I’ve done something wrong on my end.

2. Error messages and/or full log output:

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

Inside a docker compose file
caddy:
image: caddy/caddy:2.6.4-alpine
container_name: caddy-service
restart: unless-stopped
ports:
- “80:80”
- “443:443”
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./site:/srv
- caddy_data:/data
- caddy_config:/config

a. System environment:

Docker

b. Command:

c. Service/unit/compose file:

version: '3.7'
services:
    server:
        container_name: server
        restart: unless-stopped
        build:
            context: ./

    # Run the caddy server        
    caddy:
        image: caddy/caddy:2.6.4-alpine
        container_name: caddy-service
        restart: unless-stopped
        ports:
            - "80:80"
            - "443:443"
        volumes:            
        - ./Caddyfile:/etc/caddy/Caddyfile
        - ./site:/srv
        - caddy_data:/data
        - caddy_config:/config

volumes:
  caddy_data:
  caddy_config: 

d. My complete Caddy config:

api.Idontknowman.xyz {
  reverse_proxy server:4000
}

5. Links to relevant resources:

I’m pretty sure that’s not the case. Caddy doesn’t rewrite the method unless configured to do so.

You can verify by adding the debug global option and look at the log output (container logs). You should see that the method sent upstream is the same.

2 Likes

Thanks for the response. That debug global option helped to narrow it down and see the issue clearly. The issue was that I had was that I had a double slash in the url like so in postman: https://example.com//upload. Removing the duplicate slash at the end resolved the issue.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.