C# 使用nginx在根目录中托管mvc net内核,在子目录中托管临时版本
其想法是在网站根目录中提供生产mvc net core应用程序,并在子目录中提供登台版本:C# 使用nginx在根目录中托管mvc net内核,在子目录中托管临时版本,c#,asp.net-mvc,nginx,.net-core,nginx-config,C#,Asp.net Mvc,Nginx,.net Core,Nginx Config,其想法是在网站根目录中提供生产mvc net core应用程序,并在子目录中提供登台版本: (制作) (登台) 目前nginx中的配置如下: upstream myapp{ server localhost:5000; } upstream premyapp{ server localhost:6000; } server { listen *:80; add_header Strict-Transport-Security max-age
- (制作)
- (登台)
upstream myapp{
server localhost:5000;
}
upstream premyapp{
server localhost:6000;
}
server {
listen *:80;
add_header Strict-Transport-Security max-age=15768000;
return 301 https://$host$request_uri;
}
server {
listen *:443 ssl;
server_name my.website.com;
ssl_certificate /home/vhost/ssl/myapp.crt;
ssl_certificate_key /home/vhost/ssl/myapp-decrypted.key;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on; #ensure your cert is capable
ssl_stapling_verify on; #ensure your cert is capable
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
location / {
proxy_pass http://myapp;
}
location /pre {
proxy_pass http://premyapp;
}
}
而startup.cs
文件中的配置具有以下配置:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
if (env.IsStaging())
{
app.UseStaticFiles("/pre");
app.UsePathBase("/pre");
}
else app.UseStaticFiles();
...
}
但它不工作,生产应用程序不会重定向到任何控制器,临时应用程序也不会加载静态文件
有什么想法吗?问题出在静态文件配置中,现在是:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
if (env.IsStaging())
{
app.UsePathBase("/pre");
app.UseStaticFiles();
}
...
}
成功了