欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

nginx 动静态分离demo

程序员文章站 2024-02-14 16:09:58
...
server {
        listen       80;
        server_name  www.zhaosc.com;
    index  index.jsp index.html index.htm;
    root   /usr/local/nginx/html;
        location / 
    {
            proxy_next_upstream http_502 http_504 error timeout invalid_header;
            proxy_set_header Host  $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://web1;
        }

       # location ~ .*\.(php|jsp|cgi|shtml)?$
       #  {
       #     proxy_set_header Host  $host;
       #        proxy_set_header X-Real-IP $remote_addr;
       #        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       #        proxy_pass http://jvm_web2;
       # }

        location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
    {
            root /var/local/static;
        expires    30d;
        }
    access_log  /usr/local/logs/web2/access.log main;
    error_log   /usr/local/logs/web2/error.log  crit;

    }

转载于:https://www.jianshu.com/p/62d6fcc989c8