前端要懂的nginx配置

多服务接口nginx反向代理

```js

server {
    listen       80;
    server_name  xx.xx.xx.com;  // 前端部署的域名
    root /med;
    index  index.html index.htm;
    client_max_body_size 40M;
    access_log  /med/log/access.log main ;

    location ~ /api/v1 {
   
        proxy_set_header Host xx.xx.xx.com; // 服务端服务域名
        proxy_pass http://xx.xx.xx.com;
        proxy_http_version 1.1;
        proxy_connect_timeout 500s;
        proxy_read_timeout 500s;
        proxy_send_timeout 500s;
    }

location / {
        try_files $uri /index.html;
    }

    location ~* .*(html|json)$ {
        expires -1s;
        add_header 'Cache-Control' 'no-store';
    }
```
posted @ 2019-12-23 20:35  晚安喵  阅读(310)  评论(0编辑  收藏  举报