0

Context: I've got an application that run under a given domain. But in some cases I need to run it under another domain than the domain it expect (I also change potentially the port).

I'm trying to custom the fastcgi_param HTTP_HOST, but the application still receive the "real" one.

Here is what I tried as configuration:

location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass php:9000; fastcgi_index app.php; fastcgi_param SCRIPT_FILENAME /app/web$fastcgi_script_name; fastcgi_intercept_errors on; include fastcgi_params; fastcgi_param SERVER_NAME my-app.com; fastcgi_param HTTP_HOST my-app.com; } 

There's many problems:

  1. The port is not specified in HTTP_HOST, is there a way to set only the host? (maybe a set a variable that will be use for definition of the param)
  2. This does not work at all, finally "my-app.com" is not transmitted; why?

Note: this is based on nginx docker image.

1
  • You can specify the PHP environment variables in php-fpm config. Remember to uncomment the following ;clear_env = no Commented Jan 1, 2019 at 16:50

1 Answer 1

0

Found the problem:

I have many server part in my nginx configuration. I didn't mention it because I though nginx take the last if no match. But it's actually the complete opposite. I put the right server part as first one and it's working.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.