nginx提供没有ssl的静态文件

时间:2016-11-15 09:30:51

标签: ssl nginx

对于我的项目的增量速度,我想要没有ssl的服务静态文件,问题是我非常初学nginx,我的实际nginx配置是:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}

server {
    listen 443;
    ssl on;

    gzip on;
    gzip_min_length 1000;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;
    gzip_disable "MSIE [1-6]\.";
    gzip_vary on;

    server_name  selfmarket.net www.selfmarket.net;

    ssl_certificate /etc/letsencrypt/live/selfmarket.net/cert.pem;        # path to your cacert.pem
    ssl_certificate_key /etc/letsencrypt/live/selfmarket.net/privkey.pem;    # path to your privkey.pem

    fastcgi_param   HTTPS               on;
    fastcgi_param   HTTP_SCHEME         https;

    # Serve static files and uploads
    location ^~ /static/ {
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control "public";
        root /opt/master/app/;
    }

    location / {
        proxy_pass 'http://127.0.0.1:8080/';
        proxy_redirect     off;
        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_set_header   X-Forwarded-Host $server_name;
    }
}

在这一刻我强制ssl中的所有流量,需要更改静态不使用ssl。我怎么能这样做?

0 个答案:

没有答案