系统相关
首页 > 系统相关> > nginx配置

nginx配置

作者:互联网

worker_processes 2;
events {
worker_connections 65535;
}

http {
include mime.types;
default_type application/octet-stream;
#提高操作文件的效率
sendfile on;
#隐藏nginx版本号
server_tokens off;
#将响应头和正文的开始部分一起发送
tcp_nodelay on;
#客户端的长连接在服务器端保持的最长时间
keepalive_timeout 180;
#gzip模块设置
gzip on;
gzip_buffers 4 64k;
gzip_comp_level 4;
gzip_min_length 1000;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain application/json application/javascript application/x-javascript text/css text/javascript image/jpeg image/gif image/png;
#upstream proxy 配置
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;

# 设备管理访问接口
upstream mangement-api{
server 10.122.145.176:8081;
}

# 设备监控访问接口
upstream monitor-api{
server 10.122.145.176:8082;
}

# 设备运营访问接口
upstream usage-api{
server 10.122.145.176:8083;
}

server {

listen 8080;
server_name localhost;

location / {
root html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}

location /api/users {
proxy_pass http://10.160.149.33:8003/usermanager_api/api/users;
}

location /api/equipments {
proxy_pass http://mangement-api;
}

location /api/monitor {
proxy_pass http://monitor-api;
}

location /api/usage {
proxy_pass http://usage-api;
}

#静态文件客户端缓存一个月
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 30d;
}

error_page 500 502 503 504 /50x.html;

location = /50x.html {
root html;
}

}
}

 

标签:配置,html,server,nginx,api,proxy,gzip,location
来源: https://www.cnblogs.com/wangdayea/p/16359942.html