Nginx 部署前后端分离项目(SpringBoot Vue)
今天讲解一下,对于前后端分离项目Nginx如何配置
nginx配置文件
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
#include /etc/nginx/conf.d/*.conf;
server {
listen 443 ssl;
server_name www.domain.cn; #申请的域名
ssl_certificate /usr/sell-api/key/XXXXXXXX.crt; #从阿里云获取秘钥文件
ssl_certificate_key /usr/sell-api/key/XXXXXXXX.key; #从阿里云获取秘钥文件
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location /admin {
alias /usr/sell;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /prod-api/{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/;
}
}
}
以上,只演示单台服务器(单机)部署形式
更多关于Nginx的配置,请查看《实战Nginx_取代Apache的高性能Web服务器.pdf》