nginx 配置vue项目


user  root;
worker_processes  1;

#error_log  logs/error.log;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

http{

        include       mime.types;
        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  logs/access.log  main;

        sendfile        on;
        #tcp_nopush     on;
        #post_entry_max_size
        client_max_body_size 200m;
        #keepalive_timeout  0;
        keepalive_timeout  15s;

        gzip  on;
        gzip_http_version 1.0;
        gzip_comp_level 2;
        gzip_proxied any;
        gzip_min_length 1100;
        gzip_buffers 16 8k;
        # Some version of IE 6 don't handle compression well on some mime-types,
        # so just disable for them
        gzip_disable "MSIE [1-6].(?!.*SV1)";
        # Set a vary header so downstream proxies don't send cached gzipped
        # content to IE6
        gzip_vary on;
        #end gzip

        #cache begin
        proxy_buffering on;
        proxy_cache_valid any 10m;
        proxy_temp_path /home/temp;
        proxy_buffer_size 4k;
        proxy_buffers 100 8k;
        #cache end

        #https server设置实际操作
    server {
            listen       80;
            server_name  mee.dongfeng-nissan.com.cn;
            charset utf-8;
            access_log  logs/host.access.log  main;

        location / {
         root /home/dist;
                try_files $uri $uri/ /index.html last;
                index index.html;
        }
        location /api {
                proxy_pass http://127.0.0.1:8084/;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header Host $host;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_http_version 1.1;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection "upgrade";
                        rewrite /wss/(.*) /$1 break;
                        proxy_redirect off;
                        proxy_connect_timeout 4s;
                        proxy_read_timeout 7200s;
                        proxy_send_timeout 12s;

        }
        location /wxqyh/ {
                proxy_pass http://127.0.0.1:8080/wxqyh/;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header Host $host;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_http_version 1.1;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection "upgrade";
                        rewrite /wss/(.*) /$1 break;
                        proxy_redirect off;
                        proxy_connect_timeout 4s;
                        proxy_read_timeout 7200s;
                        proxy_send_timeout 12s;

        }
        location /admin/ {
                proxy_pass http://127.0.0.1:8081/admin/;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                #add_header Access-Control-Allow-Origin *;
        }
        location /fileweb/ {
                proxy_pass http://127.0.0.1:8082/fileweb/;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                #add_header Access-Control-Allow-Origin *;
        }
            #error_page  404              /404.html;
            #redirect server error pages to the static page /50x.html
            #error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    }
}

 

你可能感兴趣的:(nginx)