nginx 配置示例

转发配置示例

worker_processes  1;

user root;

events {
    worker_connections  10240;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size 200M;
    client_header_buffer_size 8k;
    large_client_header_buffers 8 16k;

    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  on;

    sendfile        on;

    keepalive_timeout  300;

    gzip  on;
    gzip_http_version 1.0;
    gzip_disable "MSIE [1-6].";
    gzip_types text/plain application/x-javascript text/css text/javascript;


    server {
        listen       80;
        server_name  demo.test.com; //测试域名
        client_header_buffer_size 8k;
        large_client_header_buffers 8 16k;


        root   /root/static/qsz/admin; //默认资源存放路径
        index login.html;

        access_log  /root/static/qsz/admin/log/host.access.log   main;

        location ~* base.js$ // base.js 单独的规则
        {
            root /root/static/qsz/admin; 

        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|woff2|woff|ttf)$ //已这些后缀结尾的规则
        {
            root /root/static/qsz/public; //存放路径
            if (-f $request_filename) {
                expires 1d; //缓存1天
                break;
            }
        }

        location ~ .*\.(js|css)$
        {
            root /root/static/qsz/public;

        }

        location /management/ {
            # 把 /management 路径下的请求转发给真正的后端服务器
            proxy_pass http://127.0.0.1:8089/management/;
            proxy_cookie_path  /management/ /;
            proxy_set_header   Host    $host;
            proxy_set_header Cookie $http_cookie;
            proxy_set_header   Remote_Addr    $remote_addr;
            proxy_set_header   X-Real-IP    $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

            client_max_body_size 200m;

            proxy_connect_timeout 18000;

            proxy_send_timeout 18000;

            proxy_read_timeout 18000;
        }
    }

    

    
}
image
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 我生于1984年,今年30有4,上有老下有小,什么都不突出腰间盘突出,觉悟不高尿酸高,所以不要跟我谈觉悟,对不起,戒了!
    加菲_f309阅读 218评论 0 0
  • 亲爱的菡宝宝: 昨天居委会有个绿色上网活动,原本打算让你听一下,你说自己不想听,就没有报名。今天居委会有个釉上彩绘...
    米米_524c阅读 76评论 0 1
  • 亲爱的咚咚: 感谢你参加了“一诺财商训练营”,21天的学习让你从理财小白,蜕变成一位理财初识者。懂得如何让钱生...
    咚咚224阅读 584评论 0 2