我有一个用 Angular 7 编写的应用程序,我将它部署到带有 NGINX 的 Docker 容器中。当我运行容器时,一切正常,除非我在浏览器中刷新页面 (F5) 我得到一个 NGINX 404 错误页面。
这是我的 nginx.conf 文件,您可以从中看到我尝试过的“try_files”
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri /index.html;
}
}
} …
Run Code Online (Sandbox Code Playgroud) 我有一个在Docker中运行的ASP.Net Core 2解决方案,它在运行VS 2017 Professional的一台机器上运行正常,但是在运行VS 2017 Community的另一台机器上却出现以下错误
“ System.InvalidOperationException:'只能使用IApplicationBuilder.UsePathBase()配置路径库。
当我尝试使用docker启动或调试解决方案时。如果我使用IIS Express启动解决方案,则效果很好。
我的项目没有什么特别的:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run(); // <- Exception happens here
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.CaptureStartupErrors(true)
.UseStartup<Startup>()
.Build();
}
public class Startup
{
public Startup(IHostingEnvironment env)
{
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
// …
Run Code Online (Sandbox Code Playgroud)