nginx部署客户端网站

nginx1.9.9 配置文件如下

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;

    server {
        listen       80;
        server_name  localhost;
        client_max_body_size 10m;
        index index.html index.htm;
        # 允许跨域请求的域,*代表所有
        add_header 'Access-Control-Allow-Origin' *;
        # 允许带上cookie请求
        add_header 'Access-Control-Allow-Credentials' 'true';
        # 允许请求的方法,比如 GET/POST/PUT/DELETE
        add_header 'Access-Control-Allow-Method' *;
        # 允许请求的header
        add_header 'Access-Control-Allow-Headers' *;
        #access_log  logs/host.access.log  main;
        location ~ \.(json|ttf|json|gif|htm|html|swf|js|css|jpg|jpeg|png|bmp|ico|wma|wmv|asf|mp3|mmf|zip|rar|flv|md|txt|apk|xls|wav|eot|woff|mp4)$ {
            #静态网页地址
            root /home/dist;
            index index.html;
        }

        location ~ ^/$
        {
             #静态网页地址
             root /home/dist;
        }
        location / { 
            proxy_pass http://10.156.104.213:8733/;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Real-Port $remote_port;
            #静态网页首页地址
            index /home/dist/index.html;
        }
       
        #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;
        }
    }
}

 

posted @ 2021-02-20 16:04  半马  阅读(181)  评论(0编辑  收藏  举报