V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
hguandl
V2EX  ›  NGINX

nginx+apache 如何设置才能解决 http 静态资源被拦截的问题?

  •  
  •   hguandl · 2017-07-12 16:16:08 +08:00 · 3070 次点击
    这是一个创建于 2451 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我的 nginx 设置如下:

    server {
    	listen 80 default_server;
    	listen 443 default;
    	ssl on;
            ssl_certificate /root/certificate.crt;
            ssl_certificate_key /root/private.key;
    	server_name _;
    	return 403;
    }
    
    server {
    	listen 443;
    	listen 80;
    	server_name example.com www.example.com;
    	ssl on;
    	ssl_certificate /root/certificate.crt;
    	ssl_certificate_key /root/private.key;
    	location ~ \.php$ {
    		proxy_pass http://localhost:800;
                    }
    	error_page 497 https://$host$uri?$args;
    }
    
    

    我这样写的目的是阻止用 IP 直接访问以及强制使用 https 访问网页,想的是利用反向代理,使得连接到 nginx 用 https,然后服务器内部是直接转到 httpd 的 800 端口。但是有一个问题在于浏览器的安全策略会认为 httpd 里的 http 静态资源不安全,从而拒绝访问,如下图: QQ20170712-155955.png 我想问一下能像我设想的那样连到 nginx 是 https,然后内部的转发用 http 吗?该如何设置,谢谢

    4 条回复    2017-07-13 11:36:07 +08:00
    Showfom
        1
    Showfom  
       2017-07-12 16:22:50 +08:00
    这和你 nginx 没关系啊

    你 WP 的 URL 设置
    zuolan
        2
    zuolan  
       2017-07-12 16:25:20 +08:00
    看起来是 wp 没有设置域名吧?
    msg7086
        3
    msg7086  
       2017-07-12 16:32:50 +08:00
    网页上的链接和你用的服务器没关系 = =
    lslqtz
        4
    lslqtz  
       2017-07-13 11:36:07 +08:00
    https 引入 http 的链接不报错才怪
    这是常识了吧?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5288 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 09:27 · PVG 17:27 · LAX 02:27 · JFK 05:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.