如何从外部访问在我的PC上运行的Java servlet? [英] How to access Java servlet running on my PC from outside?

查看:347
本文介绍了如何从外部访问在我的PC上运行的Java servlet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Netbeans6.7编写了一个servlet,当它运行时,它打开一个浏览器窗口,其地址为: http://localhost:8080/My_App/Test_Servlet ,我用我的IP地址替换了"localhost",现在看起来像这样: http://192.???.1.??:8080/My_App/Test_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

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

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

部分成功!在阅读文章,设置静态IP,端口警告之后,我可以从Paypal的测试IPN页面发送一条消息,当我尝试发送第二条消息却无法通过时,因此我停止启动servlet,然后我可以再发送一次ONE,消息,第二次再次失败,为什么? 弗兰克

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

推荐答案

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

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

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

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.

要允许来自外部世界的呼叫到您的PC,请执行以下操作:

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

  • 您的PC需要在您希望接听电话的任何时间接通(如果是PayPal IPN,几乎总是这样)
  • 您必须具有用于Internet连接的静态IP地址,或使用动态DNS 服务
  • 您必须为PayPal提供Internet连接的静态IP地址(而不是PC内部的IP地址)或您通过动态服务设置的DNS名称
  • 您必须将路由器配置为将请求转发到您的静态公共地址到计算机(因为您的路由器可能支持多台计算机,并且需要知道应该由哪个特定的计算机处理该请求)
  • 如果使用Windows防火墙之类的软件防火墙,则必须告诉它可以接受该端口上的请求.
  • 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.

这篇关于如何从外部访问在我的PC上运行的Java servlet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆