C# Nginx代理502坏网关;连接到上游时,没有带电的上游;在ASP.NET应用程序中;码头工人 有什么问题?
当我向基本应用程序端口发送请求时,一切正常 例如:C# Nginx代理502坏网关;连接到上游时,没有带电的上游;在ASP.NET应用程序中;码头工人 有什么问题?,c#,asp.net,docker,nginx,proxy,C#,Asp.net,Docker,Nginx,Proxy,当我向基本应用程序端口发送请求时,一切正常 例如: http://my.domain.dot:5000/Api/V1/Application/GetAllApplications 但当我将其发送到nginx代理域时,我看到: https://my.domain.dot/Api/V1/Application/GetAllApplications 502坏网关 在nginx代理日志中: 连接到上游时,没有活跃的上游 Nginx代理的Docker编写文件 网络列表 C#Asp.NET应用程序Docke
http://my.domain.dot:5000/Api/V1/Application/GetAllApplications
但当我将其发送到nginx代理域时,我看到:
https://my.domain.dot/Api/V1/Application/GetAllApplications
502坏网关
在nginx代理日志中:
连接到上游时,没有活跃的上游
Nginx代理的Docker编写文件
网络列表
C#Asp.NET应用程序Dockerfile
C#Asp.NET应用程序Docker编写文件
Nginx代理最后日志
Nginx代理Letsencypt最后日志
Asp.NET AppSettings.json
Startup.cs配置方法
我感觉您的nginx配置指向了错误的端点。也请共享nginx.config。在代理撰写文件中使用自定义baseimage有什么原因吗?请在启动两个compose文件后共享docker network inspect proxy的输出。网络异常。“网络异常”是响应??不应该是这样的。它应该为您提供一个json,其中所有容器都加入了代理网络。确保情况属实。docker代理网络中没有companion_api。我在companion_api docker compose中将网络名称从默认更改为代理,并在companion_api networks中指示代理网络。这一切都解决了。你能提供你的nginx.conf吗?
version: "3"
services:
proxy:
image: jwilder/nginx-proxy
container_name: proxy
ports:
- "80:80"
- "443:443"
volumes:
- ./certs:/etc/nginx/certs
- ./vhost:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
proxy_ssh:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: proxy_ssh
volumes_from:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./acme:/etc/acme.sh
environment:
- "DEFAULT_EMAIL=email@email.email"
networks:
default:
external:
name: proxy
NETWORK ID NAME DRIVER SCOPE
95cb3f06c7bc bridge bridge local
edf088f10490 host host local
4762025d43fb mongodb bridge local
1c57024e2ca0 none null local
5713c9aeb2cd proxy bridge local
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /
COPY . ./app
WORKDIR /app
RUN dotnet restore
RUN dotnet publish -c release -o /app/App.WebApi --no-restore
FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app/App.WebApi
COPY --from=build /app/App.WebApi ./
ENTRYPOINT ["dotnet", "App.WebApi.dll"]
version: "3"
services:
web_api:
build: .
container_name: companion_api
ports:
- '5000:80'
volumes:
- ./_data:/app/App.WebApi/cache/storage
environment:
- 'VIRTUAL_HOST=my.domain.dot'
- 'LETSENCRYPT_HOST=my.domain.dot'
- 'VIRTUAL_PORT=5000'
networks:
- mongodb
networks:
mongodb:
external:
name: mongodb
default:
external:
name: proxy
is being generated in the background. Once the new dhparam.pem is in place, nginx will be reloaded.
forego | starting dockergen.1 on port 5000
forego | starting nginx.1 on port 5100
dockergen.1 | 2021/04/04 12:29:15 Generated '/etc/nginx/conf.d/default.conf' from 4 containers
dockergen.1 | 2021/04/04 12:29:15 Running 'nginx -s reload'
dockergen.1 | 2021/04/04 12:29:15 Watching docker events
dockergen.1 | 2021/04/04 12:29:15 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
nginx.1 | my.domain.dot 79.110.132.102 - - [04/Apr/2021:12:29:18 +0000] "GET /Api/V1/Application/GetAllApplications HTTP/1.1" 301 169 "-" "PostmanRuntime/7.26.10"
nginx.1 | 2021/04/04 12:29:18 [error] 92#92: *2 no live upstreams while connecting to upstream, client: 79.110.132.102, server: my.domain.dot, request: "GET /Api/V1/Application/GetAllApplications HTTP/1.1", upstream: "http://my.domain.dot/Api/V1/Application/GetAllApplications", host: "my.domain.dot", referrer: "http://my.domain.dot/Api/V1/Application/GetAllApplications"
nginx.1 | my.domain.dot 79.110.132.102 - - [04/Apr/2021:12:29:18 +0000] "GET /Api/V1/Application/GetAllApplications HTTP/1.1" 502 157 "http://my.domain.dot/Api/V1/Application/GetAllApplications" "PostmanRuntime/7.26.10"
nginx.1 | my.domain.dot 79.110.132.102 - - [04/Apr/2021:12:29:19 +0000] "GET /Api/V1/Application/GetAllApplications HTTP/1.1" 301 169 "-" "PostmanRuntime/7.26.10"
nginx.1 | 2021/04/04 12:29:19 [error] 92#92: *2 no live upstreams while connecting to upstream, client: 79.110.132.102, server: my.domain.dot, request: "GET /Api/V1/Application/GetAllApplications HTTP/1.1", upstream: "http://my.domain.dot/Api/V1/Application/GetAllApplications", host: "my.domain.dot", referrer: "http://my.domain.dot/Api/V1/Application/GetAllApplications"
nginx.1 | my.domain.dot 79.110.132.102 - - [04/Apr/2021:12:29:19 +0000] "GET /Api/V1/Application/GetAllApplications HTTP/1.1" 502 157 "http://my.domain.dot/Api/V1/Application/GetAllApplications" "PostmanRuntime/7.26.10"
nginx.1 | my.domain.dot 79.110.132.102 - - [04/Apr/2021:12:29:20 +0000] "GET /Api/V1/Application/GetAllApplications HTTP/1.1" 301 169 "-" "PostmanRuntime/7.26.10"
nginx.1 | my.domain.dot 79.110.132.102 - - [04/Apr/2021:12:29:20 +0000] "GET /Api/V1/Application/GetAllApplications HTTP/1.1" 502 157 "http://my.domain.dot/Api/V1/Application/GetAllApplications" "PostmanRuntime/7.26.10"
nginx.1 | 2021/04/04 12:29:20 [error] 92#92: *2 no live upstreams while connecting to upstream, client: 79.110.132.102, server: my.domain.dot, request: "GET /Api/V1/Application/GetAllApplications HTTP/1.1", upstream: "http://my.domain.dot/Api/V1/Application/GetAllApplications", host: "my.domain.dot", referrer: "http://my.domain.dot/Api/V1/Application/GetAllApplications"
nginx.1 | my.domain.dot 79.110.132.102 - - [04/Apr/2021:12:29:22 +0000] "GET /Api/V1/Application/GetAllApplications HTTP/1.1" 502 157 "-" "PostmanRuntime/7.26.10"
nginx.1 | 2021/04/04 12:29:22 [error] 92#92: *2 no live upstreams while connecting to upstream, client: 79.110.132.102, server: my.domain.dot, request: "GET /Api/V1/Application/GetAllApplications HTTP/1.1", upstream: "http://my.domain.dot/Api/V1/Application/GetAllApplications", host: "my.domain.dot"
nginx.1 | my.domain.dot 79.110.132.102 - - [04/Apr/2021:12:29:24 +0000] "GET /Api/V1/Application/GetAllApplications HTTP/1.1" 502 157 "-" "PostmanRuntime/7.26.10"
nginx.1 | 2021/04/04 12:29:24 [error] 92#92: *2 no live upstreams while connecting to upstream, client: 79.110.132.102, server: my.domain.dot, request: "GET /Api/V1/Application/GetAllApplications HTTP/1.1", upstream: "http://my.domain.dot/Api/V1/Application/GetAllApplications", host: "my.domain.dot"
2021/04/04 12:29:35 [notice] 95#95: signal process started
Generating DSA parameters, 4096 bit long prime
dhparam generation complete, reloading nginx
Info: running letsencrypt-nginx-proxy-companion version v2.0.2-37-gc8c1f69
Info: Custom Diffie-Hellman group found, generation skipped.
Reloading nginx proxy (afb27c1f1625f6c6883faf61dd9a457ec67225ac09436e7b3706f55d7941560a)...
2021/04/04 12:29:16 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification ''
2021/04/04 12:29:16 [notice] 67#67: signal process started
2021/04/04 12:29:16 Generated '/app/letsencrypt_service_data' from 4 containers
2021/04/04 12:29:16 Running '/app/signal_le_service'
2021/04/04 12:29:16 Watching docker events
2021/04/04 12:29:16 Contents of /app/letsencrypt_service_data did not change. Skipping notification '/app/signal_le_service'
Reloading nginx proxy (afb27c1f1625f6c6883faf61dd9a457ec67225ac09436e7b3706f55d7941560a)...
2021/04/04 12:29:17 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification ''
2021/04/04 12:29:17 [notice] 91#91: signal process started
Creating/renewal my.domain.dot certificates... (my.domain.dot)
[Sun Apr 4 12:29:18 UTC 2021] Domains not changed.
[Sun Apr 4 12:29:18 UTC 2021] Skip, Next renewal time is: Thu Jun 3 00:31:08 UTC 2021
[Sun Apr 4 12:29:18 UTC 2021] Add '--force' to force to renew.
Sleep for 3600s
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "App.WebApi v1"));
}
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}