Flutter 如何在远程服务器上运行dart http服务器
我有一台Ubuntu20.04服务器,我已经成功运行了一台apache服务器,我可以从Internet访问具有ip地址(或域)的站点。但是使用dart,可以从127.0.0.1/localhost的服务器访问它,但我无法从Internet访问该站点。我怎样才能解决这个问题Flutter 如何在远程服务器上运行dart http服务器,flutter,ubuntu,dart,Flutter,Ubuntu,Dart,我有一台Ubuntu20.04服务器,我已经成功运行了一台apache服务器,我可以从Internet访问具有ip地址(或域)的站点。但是使用dart,可以从127.0.0.1/localhost的服务器访问它,但我无法从Internet访问该站点。我怎样才能解决这个问题 飞镖 飞镖跑 使用Apache systemctl启动apache2 我试过的 关闭apache服务器并将dart服务器端口更改为80,不工作 在防火墙中添加端口配置 代码 无依赖项,文件中的所有代码
- 飞镖
飞镖跑
- 使用Apache
systemctl启动apache2
dart创建tmp
cd-tmp
vi-bin/tmp.dart
飞镖跑
导入'dart:io';
void main(列出参数){
打印(“你好,世界!”);
HttpServer.bind(InternetAddress.loopbackIPv4,80)。然后((服务器){
侦听((请求){
request.response.statusCode=200;
request.response.write(“--”);
request.response.close();
});
});
}
多亏了@julemand101,这都是我的错……只需将InternetAddress更改。环回IPv4
到InternetAddress。任何IPv4
都可以正常工作 InternetAddress.loopbackIPv4
是127.0.0.1
,因此您只允许来自应用程序运行的同一服务器的流量。请尝试改用InternetAddress.anyIPv4
。@julemand101谢谢!!!它起作用了!