Date: 2025-07-30
Context: VPS/Docker-based host with containers, exposing a laptop dev server to a public domain securely.
Allow a developer laptop running a local server (e.g., localhost:6006
) to be exposed publicly as dev.mydomain.com
, securely and only when needed.
[ Public Domain: dev.mydomain.com ]
↓
[ Apache Virtual Host (port 2280) ]
↓
[ Docker Container: service.web_1 ]
↓
http://service.devproxy.site:6911
↓
[ Docker Container: service.devproxy.site ]
↓
http://host.docker.internal:4001
↓
[ socat port forward: 4001 → localhost:4000 ]
↓
[ SSH tunnel: 4000 (VPS) → 6006 (Laptop) ]
<VirtualHost *:2280>
ServerName dev.mydomain.com
ProxyPreserveHost On
ProxyPass / http://service.devproxy.site:6911/
ProxyPassReverse / http://service.devproxy.site:6911/
</VirtualHost>
ssh -N -R 4000:localhost:6006 youruser@yourserver.com
#!/bin/bash
set -e
sudo ufw allow 4001/tcp
sudo pkill -f "socat TCP-LISTEN:4001" || true
nohup sudo socat TCP-LISTEN:4001,fork,reuseaddr TCP:localhost:4000 > "$HOME/socat_devproxy.log" 2>&1 &
sudo docker-compose -f ../../docker-compose.yml up -d --force-recreate service.devproxy.site
#!/bin/bash
set -e
sudo pkill -f "socat TCP-LISTEN:4001" || true
sudo ufw delete allow 4001/tcp || true
localhost:6006
)4000 → 6006
)enable-devtunnel.sh
https://dev.mydomain.com
disable-devtunnel.sh
This NGINX container proxies requests to the developer's laptop through the forwarded port.
FROM nginx:1.27-alpine
# Copy custom nginx config
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 6911
CMD ["nginx", "-g", "daemon off;"]
events { }
http {
server {
listen 6911;
location / {
proxy_pass http://host.docker.internal:4001;
proxy_connect_timeout 1s;
proxy_read_timeout 5s;
proxy_next_upstream error timeout;
error_page 502 504 = @offline;
}
location @offline {
return 200 '{"status":"offline"}';
add_header Content-Type application/json;
}
}
}
© 2019–2025 Weplex Comunicação. Atendemos presencialmente em Ribeirão Preto, na Maurílio Biagi 800, Sala 1104 (SP) ou remotamente, profissionais liberais de todo Brasil e do mundo.
Meplex Comunicações, Weplex Comunicações, Weplex Communications e xBio são marcas registradas de Weplex Comunicações. Todo o conteúdo deste site está protegido por direitos autorais © 2019–2025 Weplex Comunicações. Todos os direitos reservados.