yum install -y nginx
systemctl start nginx.service
systemctl enable nginx.service
systemctl stop nginx.service
systemctl restart nginx.service
修改配置文件
vim /etc/nginx/nginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
#请求不包含/api/ http服务
location ^(?!.*api) {
}
#请求包含/swagger/ swagger
location /swagger/ {
proxy_pass https://localhost:5001;
}
#请求包含/api/ 反向代理
location /api/ {
proxy_pass https://localhost:5001;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
systemctl restart nginx.service