用于Kestrel的ASP.NET核心Apache反向代理

时间:2016-10-09 19:03:26

标签: asp.net apache nginx reverse-proxy

我想测试" new"我的Ubuntu服务器上的ASP.NET Core。我使用Apache,但官方文档(https://docs.asp.net/en/latest/publishing/linuxproduction.html)仅涵盖Nginx。有人可以帮助我翻译" Apache VHost的反向代理的Nginx配置?

server {
    listen 80;
    location / {
        proxy_pass http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
     

来源:ASP.NET核心文档(见上文)

对于SSL:https://docs.asp.net/en/latest/publishing/linuxproduction.html#configure-ssl

2 个答案:

答案 0 :(得分:1)

您可以使用Proxy library for ASP.NET Core

 app.UseWebSockets()
     .Map("/api", api => api.RunProxy(new Uri("http://localhost:8833")))
     .Map("/image", api => api.RunProxy(new Uri("http://localhost:8844")))
     .Map("/admin", api => api.RunProxy(new Uri("http://localhost:8822")))
     .RunProxy(new Uri("http://localhost:8811"));

检查更多详情here

答案 1 :(得分:0)

自从我提出这个问题以来,已经更新了(仍然相当新的)ASP.NET Core的可用文档。这里有一篇文章的两个链接(感谢David Peden),它解释了Apache所需的配置。即使他们以CentOS为目标,将它们用于Ubuntu也没有问题。

相关问题