2017-06-20 83 views
0

我已经通过IdHTTP-组件创建一个HTTP server,现在我想通过互联网来访问它。我从文本文件发布了一个字符串。访问本地主机通过互联网

我可以通过它accesss:

http://localhost

但我怎么通过互联网存取权限吗?我试过http://[myexternalIPaddress]:80但我没有得到答复。

这是我的代码:

procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext; 
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); 
var 
    myFile : TextFile; 
    text: String; 
begin 
    AssignFile(myFile, 'C:\Users\xxx\Desktop\test.txt'); 
    Reset(myFile); 
    ReadLn(myFile, text); 
    AResponseInfo.ContentText := text; 
end; 

procedure TForm1.FormCreate(Sender: TObject); 
begin 
    IdHTTPServer1.Active := True; 
end; 
+1

你需要的端口转发您的路由器。在路由器中打开端口80(并允许在防火墙中进行连接) – Jer

回答

1

您需要配置Windows防火墙(如果启用),允许80端口的入站连接,并且还需要配置网络路由器(如果有的话)将入站连接转发到您的路由器公共IP上的端口80到您服务器上的端口80。