如何从外部访问我的 PC 上运行的 Java servlet?

发布于 2024-08-26 14:27:28 字数 777 浏览 5 评论 0原文

我使用Netbeans6.7编写了一个servlet,当它运行时,它会打开一个浏览器窗口,地址为: http:// /localhost:8080/My_App/Test_Servlet,我用我的 IP 地址替换了“localhost”,现在它看起来像这样: http://192.???.1.??:8080/My_App/Test_Servlet,但我尝试从家外的另一台计算机访问它,它无法读取任何内容,我想知道是否需要更改 Windows 防火墙设置以允许外部流量,它是 Paypal IPN 应用程序,所以我致电 Paypal,他们说他们无法访问: http://192.???.1.??:8080/My_App/Test_Servlet

我应该怎么做才能允许来自“paypal.com”的流量访问“My_App/Test_Servlet”?


部分成功!在我阅读文章、设置静态 IP、端口转发后,我可以从 Paypal 的测试 IPN 页面发送一条消息,当我尝试发送第二条消息时,它无法通过,所以我停止启动我的 servlet,然后我可以再发一条消息,第二条又失败了,为什么? 坦率

I used Netbeans6.7 to write a servlet, when it runs, it opens a browser window with this address : http://localhost:8080/My_App/Test_Servlet, I replaced the "localhost" with my IP address, now it looks like this : http://192.???.1.??:8080/My_App/Test_Servlet, but I tried to access it from another computer outside my home, it can't read anything, I wonder if I need to change Windows Fire Wall setting to allow outside traffic, it's a Paypal IPN app, so I call Paypal, they said they can't access : http://192.???.1.??:8080/My_App/Test_Servlet

What on my side should I do to allow traffic from "paypal.com" to access "My_App/Test_Servlet" ?


Partial success ! After I read the articles, set up static IP, port forwaring, I can send one message from Paypal's test IPN page, when I tried to send a second one it couldn't go through, so I stop started my servlet, then I could send another ONE, message, failed again on the 2nd one, why ?
Frank

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

零度° 2024-09-02 14:27:28

我无法决定是否将其投票给 serverfault.com 还是 superuser.com,所以哎呀,我在这里回答:

您引用的 IP 地址看起来像本地地址(192.168.xx 是本地范围之一) ,例如),因此永远无法从网络外部访问该地址。这是您的路由器(或调制解调器)分配给您的地址。

要允许从外部世界到您的 PC 的呼叫:

  • 您的 PC 需要在任何时候您等待一个呼叫时处于开启状态(如果是 PayPal IPN,则几乎总是如此)
  • 您必须有一个静态 IP 地址您的互联网连接,或使用动态 DNS 服务
  • 您必须向 PayPal 提供您的静态 IP 地址互联网连接(不是您 PC 的内部连接)或您使用动态服务设置的 DNS 名称
  • 您必须配置您的路由器,以便将对您的静态公共地址的请求转发到您的计算机(因为您的路由器可能支持多台计算机,并且需要知道哪个特定的端口应该处理该请求)
  • 如果您使用 Windows 防火墙等软件防火墙,则必须告诉它它可以接受该端口上的请求。

不要让这看起来令人畏惧。这很重要,但并不难。但请注意,一旦您告诉路由器将端口转发给您,您就绕过了路由器可能提供的针对计算机攻击的大部分或全部保护(在该端口上;通常是攻击者端口扫描) 。它可能不提供任何,但它可能提供一些。

I couldn't decide whether to vote this over to serverfault.com or superuser.com, so heck, I'm answering here:

The IP address you've quoted looks like a local address (192.168.x.x is one of the local ranges, for instance), so that address is never accessible from outside your network. That's an address your router (or modem) has assigned to you.

To allow a call from the outside world to your PC:

  • Your PC needs to be on any time you're expecting one of the calls (and if it's a PayPal IPN, that's pretty much always)
  • You have to have a static IP address for your internet connection, or use a dynamic DNS service
  • You have to give PayPal the static IP address of your internet connection (not your PC's internal one) or the DNS name you have set up with the dynamic service
  • You have to configure your router to forward requests to your static, public address to your computer (since your router probably supports multiple computers and needs to know which specific one should handle the request)
  • If you use a software firewall such as Windows Firewall, you'll have to tell it that it can accept requests on that port.

Don't let that seem daunting. This is non-trivial, but not hard. Do note, though, that as soon as you tell your router to forward a port to you, you bypass most or all of whatever protection your router may be providing against attacks on your computer (on that port; and usually attackers port-scan). It may not be providing any, but it may be providing some.

皓月长歌 2024-09-02 14:27:28

无法从外部访问您的本地 PC 上的应用程序。其一,您的 IP 地址不是静态的。当它到达您的互联网云服务提供商时,您将拥有另一个 IP 地址。

更好的解释(来自 http://portforward.com/help/portforwarding.htm):

1.) 互联网上的每一台设备都至少有一个 IP 地址。知识产权
地址是一个数字,用于
识别一个设备。了解更多
有关ip地址的信息请参阅
我们的什么是 IP 地址页面。

2.) 每个IP地址都被划分为许多端口。当一台电脑
将数据发送到另一台计算机,它
从 IP 地址上的端口发送它
到 IP 地址上的端口。

3.) 一个端口一次只能被一个程序使用。

唯一可以帮助您的解决方案是端口转发。请参阅此处以端口转发您的路由器。

There's no way of accessing your application from the outside to your local PC. For one, your IP address isn't static. By the time it reaches your Service provider to the Internet cloud, you would have had another IP address.

A better explanation (from http://portforward.com/help/portforwarding.htm):

1.) Every device on the internet has at least one ip address. The IP
address is a number that is used to
identify a device. For more
information on ip addresses refer to
our What is an IP Address page.

2.) Every IP address is divided up into many ports. When one computer
sends data to another computer, it
sends it from a port on an ip address
to a port on an ip address.

3.) A port can only be used by one program at a time.

The only solution that can help you is to Port Forward. See here to port forward your router.

笨笨の傻瓜 2024-09-02 14:27:28

您必须将路由器配置为将端口 8080 端口转发到您的 PC,并在您提供给 Paypal 的 URL 中使用路由器的外部 IP 地址。

请参阅 portfward.com

You'll have to configure your router to port forward port 8080 to your PC and use your router's external IP address in the URL you give to Paypal.

See portfward.com.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文