nginx.conf配置文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
include conf.d/flower.conf; #vue页面
include conf.d/bs_flower.conf; #后台接口
}
flower.conf配置文件
server{
listen 443 ssl;
server_name api.huaxian24.com;
ssl_certificate /etc/letsencrypt/live/huaxian24.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/huaxian24.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/huaxian24.com/chain.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM;
ssl_prefer_server_ciphers on;
ssl_session_tickets on;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header remote-port $remote_port;
charset utf-8;
location /api {
proxy_pass http://127.0.0.1:8080;
}
}
server{
listen 80;
server_name api.huaxian24.com;
location /api{
proxy_pass http://127.0.0.1:8080;
}
}
bs_flower.conf配置文件
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
#https配置
server{
listen 443 ssl;
server_name bs.huaxian24.com;
ssl_certificate /etc/letsencrypt/live/huaxian24.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/huaxian24.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/huaxian24.com/chain.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM;
ssl_prefer_server_ciphers on;
ssl_session_tickets on;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header remote-port $remote_port;
charset utf-8;
location / {
root /app/src/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://127.0.0.1:8080;
}
#websocket配置
location /api/ws {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
# http配置
server{
#nginx监听的端口
listen 80;
server_name bs.huaxian24.com;
#前端页面
location / {
root /app/src/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
#后台地址
location /api {
proxy_pass http://127.0.0.1:8080;
}
#websocket配置
location /api/ws {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}