下载在基于NGINX的反向代理站点上不起作用

时间:2018-10-10 08:52:16

标签: nginx nginx-reverse-proxy nginx-config

使用NGINX进行反向代理https://www.jstor.org。在代理网站上,无论是文章的直接链接还是搜索的所有内容都可以正常工作,但是当以pdf格式下载该特定文章/电子书时,它会始终显示同一页面。

ngnix.conf如下:

###################################################################################################################################
server {
    listen  MY_IP:80;
    server_name www-jstor-org-MY_DOMAIN;
    location / {
        return 301 https://$host$request_uri;
    }
}
server {
    listen  MY_IP:443 ssl;
    server_name  www-jstor-org-MY_DOMAIN;
    ssl_certificate /etc/nginx/ssl2017/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl2017/my_domain.key;

    location / {

        add_header 'Access-Control-Allow-Origin' *;
        add_header 'Access-Control-Allow_Credentials' 'true';
        add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
        add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';

        proxy_bind MY_IP;

        proxy_pass https://www.jstor.org/;

        proxy_redirect measure.jstor.org measure-jstor-org-MY_DOMAIN;

        proxy_set_header Accept-Encoding "";

        sub_filter_types *;
        sub_filter ".jstor.org" "-jstor-org-MY_DOMAIN";
        sub_filter "static.ithaka.org" "static-ithaka-org-MY_DOMAIN";
        sub_filter "measure.jstor.org" "measure-jstor-org-MY_DOMAIN";
        sub_filter "nsmeasure.jstor.org" "nsmeasure-jstor-org-MY_DOMAIN";
        sub_filter_once off;
    }
}
server {
    listen  MY_IP:80;
    server_name measure-jstor-org-MY_DOMAIN;
    location / {
        return 301 https://$host$request_uri;
    }
}
server {
    listen  MY_IP:443 ssl;
    server_name  measure-jstor-org-MY_DOMAIN;
    ssl_certificate /etc/nginx/ssl2017/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl2017/my_domain.key;

    location / {

        add_header 'Access-Control-Allow-Origin' *;
        add_header 'Access-Control-Allow_Credentials' 'true';
        add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
        add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';

        proxy_bind MY_IP;

        proxy_pass https://measure.jstor.org/;

        proxy_redirect measure.jstor.org measure-jstor-org-MY_DOMAIN;

        proxy_set_header Accept-Encoding "";

        sub_filter_types *;
        sub_filter ".jstor.org" "-jstor-org-MY_DOMAIN";
        sub_filter "static.ithaka.org" "static-ithaka-org-MY_DOMAIN";
        sub_filter "measure.jstor.org" "measure-jstor-org-MY_DOMAIN";
        sub_filter "nsmeasure.jstor.org" "nsmeasure-jstor-org-MY_DOMAIN";
        sub_filter_once off;
    }
}
###################################################################################################################################

0 个答案:

没有答案