我已成功将 Nginx 配置为我的 Web 应用程序的反向代理。它正确地将从我的 Angular SPA 发出的请求重定向到用 Asp Core 2.1 编写的 Web API。但是,在我的 Web API 中,我想使用ws://mydomain.com/ws用于建立连接的WebSockets
。
这就是我现在可用的网站的样子
server {
listen 80;
listen 443;
ssl on;
ssl_certificate /etc/***/***.crt;
ssl_certificate_key /etc/***/***.key;
root /home/***/***/***/wwwroot;
# Add index.php to the list if you are using PHP
index index.html;
server_name my.domain.com;
location / {
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://localhost:5000;
}
location /api/signalr {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header Host $host; …Run Code Online (Sandbox Code Playgroud)