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;
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
gzip_disable "MSIE [1-6].";
gzip_vary on;
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;
limit_req_zone $binary_remote_addr zone=allips:10m rate=150r/s;
server {
client_max_body_size 50m;
listen 80;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET,POST';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
# 文件系统
location /file_system {
limit_req zone=allips burst=5 nodelay;
proxy_pass http://127.0.0.1:19527;
}
# 后台接口
location /api {
limit_req zone=allips burst=5 nodelay;
proxy_pass http://127.0.0.1:10086;
}
#前端页面
location / {
limit_req zone=allips burst=5 nodelay;
root /crowdsourcing/front/;
index index.html;
}
}
include /etc/nginx/conf.d/*.conf;
}