9222,暴露端口让DOCKER访问,踩坑总结

2026-04-29 09:482阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐
问题描述:

新版本都无法跨IP访问,需要下面这么搞才可以让DOCKER访问远程的机器,实现扫码登录或者短信登录

“C:\Program Files\Google\Chrome\Application\chrome.exe” --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 --remote-allow-origins=* --user-data-dir=C:\temp\chrome_debug_profile

netsh interface portproxy add v4tov4 listenport=9222 listenaddress=0.0.0.0 connectport=9222 connectaddress=127.0.0.1

网友解答:
--【壹】--:

@echo off
chcp 65001 >nul 2>&1

echo ============================================
echo Chrome CDP Remote Debugging Setup
echo ============================================
echo.

echo [1/5] Closing Chrome…
taskkill /F /IM chrome.exe >nul 2>&1
timeout /t 2 /nobreak >nul

echo [2/5] Starting Chrome (CDP mode)…
start “” “C:\Program Files\Google\Chrome\Application\chrome.exe” --remote-debugging-port=9222 --user-data-dir=“C:\selenium” --remote-allow-origins=*
timeout /t 3 /nobreak >nul

echo [3/5] Cleaning old rules…
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=9222 >nul 2>&1
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=9223 >nul 2>&1

echo [4/5] Setting portproxy (9223 → 9222)…
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=9223 connectaddress=127.0.0.1 connectport=9222

echo [5/5] Setting firewall rule…
netsh advfirewall firewall delete rule name=“Chrome CDP 9222” >nul 2>&1
netsh advfirewall firewall delete rule name=“Chrome CDP 9223” >nul 2>&1
netsh advfirewall firewall add rule name=“Chrome CDP 9223” dir=in action=allow protocol=TCP localport=9223

echo.
echo ============================================
echo Test:
echo Local: http://localhost:9222/json/version
echo LAN: http://192.168.1.204:9223/json/version
echo ============================================
echo.

echo Testing local…
curl -s http://localhost:9222/json/version | findstr “Browser” >nul 2>&1
if %errorlevel%==0 (
echo [OK] Local CDP works
) else (
echo [FAIL] Local CDP error
)

echo Testing LAN…
curl -s --connect-timeout 3 http://192.168.1.204:9223/json/version | findstr “Browser” >nul 2>&1
if %errorlevel%==0 (
echo [OK] LAN CDP works
) else (
echo [FAIL] LAN CDP error
)

echo.
pause

问题描述:

新版本都无法跨IP访问,需要下面这么搞才可以让DOCKER访问远程的机器,实现扫码登录或者短信登录

“C:\Program Files\Google\Chrome\Application\chrome.exe” --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 --remote-allow-origins=* --user-data-dir=C:\temp\chrome_debug_profile

netsh interface portproxy add v4tov4 listenport=9222 listenaddress=0.0.0.0 connectport=9222 connectaddress=127.0.0.1

网友解答:
--【壹】--:

@echo off
chcp 65001 >nul 2>&1

echo ============================================
echo Chrome CDP Remote Debugging Setup
echo ============================================
echo.

echo [1/5] Closing Chrome…
taskkill /F /IM chrome.exe >nul 2>&1
timeout /t 2 /nobreak >nul

echo [2/5] Starting Chrome (CDP mode)…
start “” “C:\Program Files\Google\Chrome\Application\chrome.exe” --remote-debugging-port=9222 --user-data-dir=“C:\selenium” --remote-allow-origins=*
timeout /t 3 /nobreak >nul

echo [3/5] Cleaning old rules…
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=9222 >nul 2>&1
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=9223 >nul 2>&1

echo [4/5] Setting portproxy (9223 → 9222)…
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=9223 connectaddress=127.0.0.1 connectport=9222

echo [5/5] Setting firewall rule…
netsh advfirewall firewall delete rule name=“Chrome CDP 9222” >nul 2>&1
netsh advfirewall firewall delete rule name=“Chrome CDP 9223” >nul 2>&1
netsh advfirewall firewall add rule name=“Chrome CDP 9223” dir=in action=allow protocol=TCP localport=9223

echo.
echo ============================================
echo Test:
echo Local: http://localhost:9222/json/version
echo LAN: http://192.168.1.204:9223/json/version
echo ============================================
echo.

echo Testing local…
curl -s http://localhost:9222/json/version | findstr “Browser” >nul 2>&1
if %errorlevel%==0 (
echo [OK] Local CDP works
) else (
echo [FAIL] Local CDP error
)

echo Testing LAN…
curl -s --connect-timeout 3 http://192.168.1.204:9223/json/version | findstr “Browser” >nul 2>&1
if %errorlevel%==0 (
echo [OK] LAN CDP works
) else (
echo [FAIL] LAN CDP error
)

echo.
pause