我的问题类似于这个 ,除了我有另一个nginx服务器后面的nginx SSL代理服务器:
-------------------------- -------------------------------- ---------- | nginx: https://bla.com | -----> | nginx: http://localhost:8080 | ----> | Joomla | -------------------------- -------------------------------- ----------
在nginx中是否有类似SetEnvIfNoCase X-Forwarded-Proto https HTTPS=on的选项?
目前,我有问题,静态内容,如JavaScript和CSS文件不服务。
前端nginx代理上的configuration:
server { listen 443; listen [::]:443 ipv6only=on; server_name bla.com; // cut ssl settings location / { 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-Proto $scheme; # Fix the “It appears that your reverse proxy set up is broken" error. proxy_pass http://localhost:8080; proxy_read_timeout 90; proxy_redirect http://localhost:8080 https://bla.com; } } server { listen 80; listen [::]:80 ipv6only=on; server_name bla.com www.bla.com; return 301 https://bla.com$request_uri; }
据我了解,我需要评估“内部”nginxconfiguration中的“X-Forwarded-Proto”头并设置HTTPS环境variables,所以joomla可以做出相应的反应( library/joomla/uri/uri.php ):
// Determine if the request was over SSL (HTTPS). if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) { $https = 's://'; } else { $https = '://'; }
我只是不知道如何:)
经过大量的研究,我find了解决办法。 在“内部”nginxconfiguration中:
http { ... map $http_x_forwarded_proto $context { https on; default off; } ... server { ... location ~ \.php$ { ... fastcgi_param HTTPS $context; ... } } }
参考资料: 这个提示在nginx邮件列表中让我find了解决scheme。