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
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Symfony compares favorably with other PHP frameworks in terms of reliability and maturity. This framework appeared a long time ago, in 2005, that is, it has existed much longer than most of the other tools we are considering. It is popular for its web standards compliance and PHP design patterns.
https://symfony.com/
CakePHP is a framework that has been around since 2005 and is known for the convenience it gives web developers. It needs very modest settings, does not require the use of XML or YAML files. It has its own ORM, which sets it apart from other similar tools. In terms of security, it is also doing well, in particular, it has a protection system against CSRF attacks.
https://cakephp.org/
JavaScript is a multi-paradigm language that supports event-driven, functional, and mandatory (including object-oriented and prototype-based) programming types. Originally JavaScript was only used on the client side. JavaScript is now still used as a server-side programming language. To summarize, we can say that JavaScript is the language of the Internet.
https://www.javascript.com/
CSS (Cascading Style Sheets) is a formal language for describing the appearance of a document written using a markup language.
It is mainly used as a means of describing, decorating the appearance of web pages written using HTML and XHTML markup languages, but can also be applied to any XML documents, such as SVG or XUL.
https://www.w3.org/TR/CSS/#css
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.