gpt4 book ai didi

magento - Nginx 在 https 域上提供非安全资源

转载 作者:太空宇宙 更新时间:2023-11-03 15:03:07 26 4
gpt4 key购买 nike

我在使用 SSL 证书设置服务器时遇到了一些问题。我能够很好地安装证书并重新启动 nginx 服务。但是,当我尝试加载我的网站时,我发现所有 img、css 和 js 文件都是通过 http 而不是 https 检索的。这是一个 Magento 网站。我的 conf 文件有问题吗?

server {
listen 80;
server_name www.my-domain.com;
return 301 $scheme://my-domain.com$request_uri;
}

server {
listen 80;
listen 443 ssl;

ssl_certificate /etc/ssl/my-domain/my-domain_com.pem;
ssl_certificate_key /etc/ssl/my-domain/my-domain_com.key;

access_log /var/log/nginx/magento.local-access.log;
error_log /var/log/nginx/magento.local-error.log;

server_name my-domain.com;
root /var/www/my-domain;

include conf/magento_rewrites.conf;
include conf/magento_security.conf;

# PHP handler
location ~ \.php {
## Catch 404s that try_files miss
if (!-e $request_filename) { rewrite / /index.php last; }

## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;

# By default, only handle fcgi without caching
include conf/magento_fcgi.conf;
}

# 404s are handled by front controller
location @magefc {
rewrite / /index.php;
}

# Last path match hands to magento or sets global cache-control
location / {
## Maintenance page overrides front controller
index index.html index.php;
try_files $uri $uri/ @magefc;
expires 24h;
}

rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;

location /lib/minify/ {
allow all;
}

}

最佳答案

可能是因为这就是它们的调用方式,如果您需要将所有内容都作为 https 提供,我会创建一个空服务器来监听 80 并重定向到 https

server {
# listen 80; delete this part
listen 443 ssl;
# the rest of the config
}
# add this server
server {
listen 80;
server_name example.com;
location / # or a more specific location '~ \.(jpg|css|js|jpeg|png|gif)' {
return https://example.com$request_uri;
}
}

或者只是修复css位置,它可能是一个带有http的绝对URL

关于magento - Nginx 在 https 域上提供非安全资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17758419/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com