反向代理后端项目
server {
listen 80;
server_name www.caojingbin.com;
client_max_body_size 20M;
location /aa/ { 拦截路径
proxy_pass http://127.0.0.1:8855/; 代理地址
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
反向代理前端项目,静态项目
server {
listen 80; 监听端口
server_name www.baidu.com; 监听ip或域名
client_max_body_size 20M;
#配置支持压缩后的静态文件
gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
#这段不是必须配置,静态资源有gizp文件时配置
location / { 拦截路径
root /usr/share/nginx/html/; 静态资源的路径
index /index.html; 静态资源名称类型
try_files $uri $uri/ /index.html; vue中history模式需要的配置,当前路径的访问转发到,静态资源的路径下的index.html
}
}
文章永久链接:https://tech.souyunku.com/24607