将硒与特定IP结合 - 可能吗? [英] Bind selenium to a specific IP - Possible?
问题描述
与许多人一样,我们通过以下命令启动selenium服务器:
Like many, we start selenium server via the following command:
java -jar selenium-server-standalone-2.21.0.jar
我们发现这是在0.0.0.0:4444
What we found is that this opens selenium up on 0.0.0.0:4444
Started SocketListener on 0.0.0.0:4444
[USER @ BOX ~]# netstat -na | grep LISTEN | grep 4444
tcp 0 0 :::4444 :::* LISTEN
有没有将selenium绑定到特定ip(localhost)的方法?
Is there any way to bind selenium to a specific ip (localhost)?
谢谢。
推荐答案
这不是处理这个问题的正确方法,但它是一种方式
This is not the correct way of handling this problem but its a way
那么这样做只是从任何外部源删除端口4444上的任何连接。你可以先测试一下
So what this will do is just drop any connection on port 4444 from any outside source. You can test this by first going to page
像这样启动服务器
java -jar selenium-server-standalone-2.39.0.jar -host 127.0.0.1 -port 4444
确认一切正常
http://yourexternalip:4444/wd/hub/
页面将加载。如果您的服务器运行正常。
the page will load. if your server is running properly.
发送命令
sudo iptables -A INPUT -p tcp --dport 4444 -s 127.0.0.1 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 4444 -j DROP
然后重新加载页面。将无法再访问该网页(因为您正在从外部IP访问)
then reload the page. the webpage will no longer be accessible (because you are accessing from external IP)
您的新可访问网址现在是
your new accessible URL is now
http://127.0.0.1:4444/wd/hub/
哪个应该正常工作
同样,这更像是一个更大问题的创可贴,这样做不会强迫你更改任何源代码保持安全的系统
Again this is more of a band-aid to a greater problem and doing this will not force you to change any source code and still keeping a secure system
这篇关于将硒与特定IP结合 - 可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!