How to debug remote Java application through nginx reverse proxy
Asked Answered
L

1

6

I need to debug a remote java application running behind an nginx reverse proxy. I get the following error:

Failed to attach to remote debuggee VM. Reason: java.io.IOException: Received invalid handshake

What should be the right nginx configuration to achieve this?

I have successfully attached vscode java debugger to the remote java application by targeting the app's host directly.

Resolver is 127.0.0.11 because I'm using nginx docker image.

My nginx config file app.xyz.com.conf in conf.d:

server {
    listen 1043;
    resolver 127.0.0.11 valid=30s;
    server_name app.xyz.com;
    include /etc/nginx/mime.types;
    location / {
        proxy_buffer_size 8k;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
        proxy_set_header X-Real-IP $remote_addr;
        set $upstream "http://java-app:1043";
        proxy_pass $upstream;
        client_max_body_size 10M;
    }
}

Thanks in advance!

Legalize answered 31/7, 2019 at 16:48 Comment(0)
F
1

You should declare tcp port instead http for debug java application.

Fury answered 26/5, 2020 at 16:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.