1.一个简单的vue前端项目的Nginx通用配置(服务器端)
server {
listen 8099;
access_log /var/log/nginx/access-ainnovation.log qizhi-ops-access;
error_log /var/log/nginx/error-ainnovation.log ;
charset utf-8;
client_max_body_size 50M;
server_name ***.com;
location ^~ /static/ {
alias /opt/www/run/erp_web_new_mobile/dist/static/;
}
location ^~ /api/ {
proxy_pass http://127.0.0.1:****;
#proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_buffer_size 4k;
}
location / {
try_files $uri $uri/ /index.html last;
index index.html index.htm;
alias /opt/www/run/erp_web_new_mobile/dist/;
}
location = /favicon.ico { log_not_found off; access_log off; }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 5d;
}
location ~ .*\.(js|css)?$ {
expires 1h;
}
2.一个简单的前端项目的Nginx配置(本地PC端)
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8088;
server_name erptest.ainnovation.com;
location / {
try_files $uri $uri/ /index.html last;
index index.html index.htm;
root D:\ainnovation\workceshi\ceshi;
}
}
}