假定使用的域名為:xxx.istk.net
,AspNetCore程序的訪問端口為http://localhost:5001
配置文件還包含:SSL配置、SignalR配置和跳過php請求。
1. 新建配置文件
創(chuàng)建新文件
vi /etc/nginx/conf.d/xxx.conf
內容如下:
server {
listen 80;
server_name xxx.istk.net;
if ( $request_uri ~ ".php" ) {
return 403;
}
return 301 https://$server_name$request_uri;
}
server {
listen 443;
server_name xxx.istk.net;
ssl on;
ssl_certificate /etc/nginx/cert/certificate.crt;
ssl_certificate_key /etc/nginx/cert/private.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL;
location / {
proxy_pass http://localhost:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
}
# SignalR
location /scheduler-hub {
proxy_pass http://localhost:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /antiscout-hub {
proxy_pass http://localhost:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /conjunction-hub {
proxy_pass http://localhost:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
2. 使Nginx重新加載配置文件
nginx -s reload