2016-02-15 85 views
0

我想服务器安全的网站使用Nginx SSL连接。我无法加载第三方HTTP CSS和JS文件。它给错误。Nginx的SSL连接

This request has been blocked; the content must be served over HTTPS. 

这里是我的nginx的conf

server { 
listen 443 ssl; 
server_name api-test.vendorver.com; 
ssl_certificate  /etc/nginx/ssl/vv_key/cert_chain.crt; 
ssl_certificate_key /etc/nginx/ssl/vv_key/vendorver.key; 
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
ssl_prefer_server_ciphers on; 
ssl_stapling on; 
ssl_stapling_verify on; 
location/{ 
    proxy_pass http://0.0.0.0:8000; 
    proxy_set_header X-Forwarded-Host $server_name; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $http_host; 
    proxy_set_header X-Forwarded-Ssl on; 
    proxy_redirect off; 
} 
#if ($host !~* ^(vendorver.com|www.vendorver.com)$) { 
# return 444; 
#} 
location /static/ { 
    autoindex on; 
    alias /home/ec2-user/vendorver.backend/static/; 
} 
} 

该文件不适用于HTTPS请求。我如何在页面中包含该文件?

回答

0

您必须配置您的静态目录和媒体(图像)目录 要运行这些基于SSL的配置应该是这样的:

server { 
    listen 80; 
    charset utf-8; 
    client_max_body_size 100M; 
    ssl on; 
    listen 443 ssl; 


    ssl_certificate /etc/nginx/ssl/yoursite_com/ssl-bundle.crt; 
    ssl_certificate_key /etc/nginx/ssl/yoursite_com/cert.key; 



    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_prefer_server_ciphers on; 
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; 

    access_log /var/www/vhosts/yoursite.com/logs/access_log; 
    error_log /var/www/vhosts/yoursite.com/logs/error_log; 
    server_name yousite.com www.yoursite.com; 

    root /var/www/vhosts/yoursite.com/yourapp/; 
    add_header Strict-Transport-Security max-age=31536000; 


    location/{ 
      .... your settings here 
    } 
    location /media { 
     alias /var/www/vhosts/yoursite.com/yourapp/media; 
    } 

    location /static { 
     alias /var/www/vhosts/yoursite.com/yourapp/static; 
    } 
    if ($scheme = http) { 
     return 301 https://$server_name$request_uri; 
    } 

}