Nginx: override host header when using fastcgi_pass

I am trying to redefine the header of the http host that is passed to my php application (in particular Phabricator ) when using fastcgi_pass.
I found many examples for this using proxy_pass, but I cannot find an example of how to do this with fastcgi_pass. In particular, I would like the php proxy application to see the host header as "phabricator.localhost".

(The reason for this is because I want to associate several different domains with the Phabricator web server, but it allows only one domain to communicate and rejects any requests not made by that single domain.)

I am new to configuring Nginx with FastCGI, so I'm not sure how fastcgi works. Any help is appreciated.

Here is my Nginx server configuration:

server { server_name phabricator.localhost www.example.com example.com; root /opt/phabricator/phabricator/webroot; location / { index index.php; rewrite ^/(.*)$ /index.php?__path__=/$1 last; } location = /favicon.ico { try_files $uri =204; } location /index.php { fastcgi_pass localhost:9000; fastcgi_index index.php; #### HERE ARE MY ATTEMPTS ##### #proxy_set_header HOST phabricator.localhost; #fastcgi_param SERVER_NAME phabricator.localhost; #fastcgi_pass_header 'Host: phabricator.localhost'; #fastcgi_pass_header 'Host: phabricator.localhost'; #add_header Host phabricator.localhost; #proxy_set_header Host phabricator.localhost; #### END ATTEMPTS #### fastcgi_param REDIRECT_STATUS 200; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; } } 
+7
php nginx fastcgi phabricator
source share
1 answer

Have you tried HTTP_HOST? The following works for me:

 fastcgi_param HTTP_HOST phabricator.localhost; 
+10
source share

All Articles