php - Convert this nginx rule : fastcgi_param HTTP_X_FORWARDED_HOST $http_referer; to apache 2.4.x configuration
one text
I try to find a way to convert this nginx rule : fastcgi_param HTTP_X_FORWARDED_HOST $http_referer; to apache 2.4.x configuration.
stack : traefik -> apache -> php (cakePHP 2.10) -> API MS Symfony 5 (all in docker stack)
current 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;
}
}
apache config :
<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>
Problem : We have some http request from cakePHP to a Microservice API Symfony 5 When the response is done from the MS, cakePHP reload the current page using $this->referer. With Nginx no problem the referer value reflect the full URL coming from cakePHP, with Apache we have juste the Host url :
Ngingx : referer = http://mydev.local/myfeat/view
Apache : referer = http://mydev.local
Could anyone help me please to fix this problem ? thx
Source