php - 转换这个 nginx 规则:fastcgi_param HTTP_X_FORWARDED_HOST $http_referer; 到 apache 2.4.x 配置
问题描述
我试图找到一种方法来转换这个 nginx 规则:fastcgi_param HTTP_X_FORWARDED_HOST $http_referer; 到 apache 2.4.x 配置。
堆栈:traefik -> apache -> php (cakePHP 2.10) -> API MS Symfony 5(全部在 docker 堆栈中)
当前的 nginx cconfiguration:
server {
root /var/www/html/app/webroot;
server_name mydev.local;
access_log /dev/stdout;
error_log /dev/stderr;
charset utf-8;
client_max_body_size 500M;
location / {
try_files $uri /index.php$is_args$args;
}
location /test {
try_files $uri /test.php$is_args$args;
}
location ~ ^/(index|test).php(/|$) {
fastcgi_pass php_mydev:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTP_X_FORWARDED_HOST $http_referer;
fastcgi_param HTTPS off;
fastcgi_buffers 4 256k;
fastcgi_read_timeout 3000;
}
}
阿帕奇配置:
<VirtualHost *:80>
ServerName mydev.local
DocumentRoot /var/www/html
<Directory "/var/www/html">
DirectoryIndex index.php
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
</Directory>
ProxyRequests On
ProxyPass "/" "reverse-proxy" # reverse proxy is the docker service for traefik
ProxyPassReverse "/" "reverse-proxy"
ProxyPreserveHost On
ProxyAddHeaders On
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
LogLevel debug
AddDefaultCharset UTF-8
Header always set Cache-Control "max-age=86400" env=cache
ProxyTimeout 900
ExpiresActive On
<FilesMatch "\.(ico|gif|jpe?g|png|js|css|svg)$">
ExpiresDefault "access plus 1 year"
</FilesMatch>
<IfModule mod_deflate.c>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/json
</IfModule>
</IfModule>
问题:我们有一些来自 cakePHP 的 http 请求到一个微服务 API Symfony 5 当来自 MS 的响应完成后,cakePHP 使用 $this->referer 重新加载当前页面。使用 Nginx 没问题,referer 值反映了来自 cakePHP 的完整 URL,使用 Apache,我们只有 Host url:
Ngingx:referer = http://mydev.local/myfeat/view
阿帕奇:referer = http://mydev.local
谁能帮我解决这个问题?谢谢
解决方案
推荐阅读
- c - 包含与主 c 文件位于同一文件夹中的 C 文件
- c# - 如何在 C# 中异步调用 Web 方法?
- javascript - 没有点击反应路线不会显示
- json - Grafana 导入一个简单的 json 文件作为数据源
- postgresql - 如何将新列添加到 postgres 中的分区表
- excel - 在 Excel 中使用高级查找函数
- google-apps-script - Google Apps 脚本:未定义参考错误 getValue
- pdf - Ghostscript 不会压缩所有 PDF
- c# - 如何将自 1970 年 1 月 1 日以来的秒数转换为日期时间值?
- angular - 使用 Azure AD B2C 时向 Angular SPA 和 MSAL 添加角色