我的aspnetcore API和Linux环境遇到了一些问题。
我有一个角度项目et 5 .net项目(API's和Worker服务),每个项目都部署在一个码头容器中,所有这些项目都是由一个对接者组成的。
我有最后一个Nginx容器,我成功地用"Letsencrypt“(对接图像)认证了我的域,该工作与我的角度项目有关。
但是,当我尝试从客户端向aspnetcore API(自签名证书)发出请求时,这一点都不起作用。
发行=> net::ERR_CERT_AUTHORITY_INVALID
所以,我读了很多关于这个问题的主题和文章,我找到了最后一篇文章:https://letsencrypt.org/docs/certificates-for-localhost/,它解释说,我们不能认证"localhost“,所以我们应该在每个浏览器中声明我们的自签名证书。
所以我的问题是:我能为所有人和每个想访问我的网站的用户做一次吗?
可能是aspnetcore和linux完全不兼容(特别是对于SSL)。
我能做什么?我现在有点迷路了..。
发布于 2022-09-28 17:59:41
通过nginx代理所有的流量,并将API设置为上游。
示例nginx config (将您已经在工作的TLS配置添加到此配置中):
worker_processes 1;
events { worker_connections 1024; }
http {
sendfile on;
upstream web-api {
server mydotnetapi:80;
}
server {
listen 80;
server_name example.com;
location /symbiosisapi/ {
proxy_pass http://web-api/;
proxy_redirect off;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $server_name;
}
location / {
autoindex on;
root /home/www-data/mysite;
}
}
}如果有人点击/位置,它将接收静态内容,如果有人点击/api位置,请求将被转发到您的dotnet。而nginx会处理所有的TLS。将mydotnetapi更改为您在撰写文件中设置的容器名称。
https://stackoverflow.com/questions/73881059
复制相似问题