[英]ASP.NET Core Deploying App Fails with Apache
I'm currently trying to learn ASP.NET Core it's really awesome so far :) I've installed the Core Runtime and everything else needed to run a WebApp, what I'm struggling the last couple hours is, that I only can access the WebApp when I use the Port in the URL like http://ip:5000
but when I try it like this http://ip/WebApp
I'm getting a 404 Error. 我目前正在尝试学习ASP.NET Core它到目前为止真的棒极了:)我已经安装了Core Runtime以及运行WebApp所需的一切,我在过去几个小时里遇到的困难是,我只能访问当我在URL中使用像http://ip:5000
这样的端口时的WebApp但是当我像这样尝试它时http://ip/WebApp
我得到了404错误。
Ubuntu 16.04 with Apache 使用Apache的Ubuntu 16.04
I'm pretty sure that I've configured everything in Apache to make it work. 我很确定我已经在Apache中配置了所有内容以使其工作。 This is my conf file in /etc/apache2/sites-available/proxy-host.conf
这是我在/etc/apache2/sites-available/proxy-host.conf
conf文件
<VirtualHost *:80>
DocumentRoot /var/www/WebApp/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
ProxyPass /WebApp http://localhost:5000
ProxyPassReverse /WebApp http://localhost:5000
ServerName localhost
</VirtualHost>
and my little sample app 和我的小样本应用程序
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true)
.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls("http://*:5000")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();
host.Run();
}
What am I missing here? 我在这里错过了什么? I'm pretty sure that this is a noob question but bare in mind that I'm trying to learn :=) 我很确定这是一个noob问题,但我记得我正在努力学习:=)
I was able to Fix this issue by changing both the config and my code in the Main Method to: 通过将主方法中的配置和我的代码更改为:我能够解决此问题:
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls("http://*:5000/WebApp")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();
host.Run();
and in the Config file 并在Config文件中
<VirtualHost *:80>
DocumentRoot /var/www/WebApp
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
ProxyPass /WebApp http://localhost:5000/WebApp
ProxyPassReverse /WebApp http://localhost:5000/WebApp
ServerName localhost
</VirtualHost>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.