【发布时间】:2021-03-24 00:59:05
【问题描述】:
所以我对这方面很陌生,但我正在尝试构建一个 Web 服务器来托管我自己的网站。它目前正在 Ubuntu 20.04 上通过我桌上的树莓派运行。
我已经完成了从服务器运行我的 .net 5 Web 应用程序的所有步骤。但是,当我尝试通过 http://192.168.1.14 访问该站点时,我得到一个奇怪的 307 重定向,并将我重定向到 https://192.168.1.14:5001。当然我也得到一个站点无法访问的错误。
我确实有我的网站 .conf 文件:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName BuildItWithDan
ServerAlias www.BuildItWithDan
DocumentRoot /var/www/BuildItWithDan
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log common
</VirtualHost>
当我运行我的 .net 5 应用程序时,我可以看到它可以正确加载和收听。
ubuntu@ubuntu:~$ /home/ubuntu/dotnet-64/dotnet /var/www/BuildItWithDan/BuildItWithDan.Web.dll
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[62]
User profile is available. Using '/home/ubuntu/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /home/ubuntu
因此,当导航到 http://192.168.1.14 时,我可以在我的服务上看到一些 ping。
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://192.168.1.14/ - -
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 GET http://192.168.1.14/ - - - 307 0 - 38.2497ms
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://192.168.1.14/ - -
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 GET http://192.168.1.14/ - - - 307 0 - 1.6625ms
也许有什么值得注意的。如果我删除(或注释掉).conf 文件中的 ProxyPass 行,我就可以使用http://192.168.1.14 连接到服务器,但它只是给了我一个目录列表。
然后,如果我更改我的 DocumentRoot 路径 DocumentRoot /var/www/html 这将使用相同的 http://192.168.1.14 加载默认的 apache 站点就好了
我还运行了sudo a2enmod proxy proxy_http 以及其他几个我想不到的。
Module proxy already enabled
Considering dependency proxy for proxy_http:
Module proxy already enabled
Module proxy_http already enabled
任何帮助将不胜感激!
编辑:我能够从日志中找到这些。
[Tue Mar 23 21:35:45.053007 2021] [proxy:error] [pid 19685:tid 281472865419664] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:5000 (127.0.0.1) failed
[Tue Mar 23 21:35:45.053198 2021] [proxy_http:error] [pid 19685:tid 281472865419664] [client 80.82.77.192:57200] AH01114: HTTP: failed to make connection to backend: 127.0.0.1
【问题讨论】:
标签: linux apache asp.net-core webserver web-hosting