这是我在Nginx中迈出的第一步,所以任何帮助都会很棒。
我有一个由两个容器组成的小型docker-compose应用程序:
Nginx的
上载
Nginx端口80暴露在主机上,以便可以从我们的Intranet像下面这样访问Nginx:www.mytest.net
现在,我将在该地址的子路径上公开asp.net核心站点“上载”,例如:
www.mytest.net/upload/
目前,我无法实现这一点,如果尝试将其移至路径上载,则上载的每个URL等均将无法使用,并且不确定是否必须配置NGINX,asp.net核心或以其他方式进行配置。
Nginx.conf中的当前配置:
location / {
proxy_pass http://upload:80;
# The default minimum configuration required for ASP.NET Core
# See https://docs.asp.net/en/latest/publishing/linuxproduction.html?highlight=nginx#configure-a-reverse-proxy-server
proxy_cache_bypass $http_upgrade;
# Turn off changing the URL's in headers like the 'Location' HTTP header.
proxy_redirect off;
# Forwards the Host HTTP header.
proxy_set_header Host $host;
# The Kestrel web server we are forwarding requests to only speaks HTTP 1.1.
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
# Adds the 'Connection: keep-alive' HTTP header.
proxy_set_header Connection keep-alive;
}
}
就像我说的那样,它可以在“/”上运行,但是如果我使用“upload”,由于网址不匹配,上载网站上的简单表单将无法使用。
最佳答案
阅读HttpContext.Request.PathBase和一个名为UsePathBase的新扩展。这些有助于隔离应用程序的根URL,因此不会弄乱您的路线。
关于nginx - 如何在子路径上找到Asp.net核心站点,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42596045/