是否可以使用nginx转发websocket实现Node远程调试?
原理大概如上,我想通过nginx转发websocket实现node的远程调试,但是发现遇到了一点坑爹的问题 首先remote2很简单的起了一个node服务,很简单的hello world那种,用pm2 配置 fork 模式启动,实例为1。之后remote2本地验证启动OK 然后配置remote 1的nginx转发如下
user nginx;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server <remote2 IP>:9229;
}
server {
listen 9229;
location / {
proxy_pass http://<remote2 IP>:9229;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header Origin "";
}
}
}
但是当我验证的时候发现Chrome Devtools可以搜索到这个Node服务,但是source面板却是空的,求指教