# nginx (or PHP?) sends wrong Location in HTTP header



## IPTRACE (Oct 25, 2016)

Hello!

OS: FreeBSD 11-RELEASE
Engine: nginx-1.10.1_2,2
App language: php70-7.0.12
CMS: Symfony 1.4

I have a problem with Location in HTTP header.

Old server (Apache, PHP5) reply for all browsers:
Location: http://www.my.web/

New server (nginx, PHP7) reply for all browsers:
: http: //www.my.web/

The above generates problem only on Edge & IE which cannot handle it during login redirection.
I've forced to add Location HTTP header in nginx but I think it's not a solution. It generates another problem although login redirection works properly.

Please read a post on http://stackoverflow.com/questions/...nt-redirect-after-login-and-get-http-302-code where all I've described with details.

Thanks for your help.
Arek


```
location /
                        {
                                root   /www/data;
                                index  index.php index.html index.htm;
                                try_files $uri $uri/ /index.php?q=$request_uri;
                        }

                location ~ \.php($|/)
                        {
                                set  $script     $uri;
                                set  $path_info  "";

                                if ($uri ~ "^(.+\.php)(/.+)")
                                        {
                                                set  $script     $1;
                                                set  $path_info  $2;
                                        }

                                try_files       $uri = 404;
                                root    /www/data;
                                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                                fastcgi_pass    127.0.0.1:9000;
                                #fastcgi_index   index.php;
                                fastcgi_read_timeout 600;
                                fastcgi_buffers 8 64k;
                                fastcgi_buffer_size 128k;
                                fastcgi_connect_timeout 600;
                                fastcgi_send_timeout 600;
                                fastcgi_param   SCRIPT_FILENAME $document_root$script;
                                fastcgi_param  PATH_INFO        $path_info;
                                include         fastcgi_params;
                                fastcgi_param   SCRIPT_NAME     $script;
                                add_header      Location        $script always;
                        }
```


----------



## spag (Oct 26, 2016)

why you add ?

```
add_header      Location        $script always;
```
in general this looks more as a php software issue.

check in here: https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/


----------



## IPTRACE (Oct 26, 2016)

Because on TCP stack in data field "Location: http://www.my.web" is not available. Instead of that I have ": http: //www.my.web" and I suppose that Edge&IE cannot parse it or do it strange things to "Hmm, we can't reach this page."
I investigated it through Wireshark. So I added the header for Edge&IE that they could understand what should they do.

I was trying a lot of nginx examples and for me works mine.
It was difficult because I transferred web data to the new server from very old one (2008 year) which has not been updated completely and where were old Apache and PHP5.


----------



## SirDice (Oct 26, 2016)

Why didn't you use Apache for the new server? The configuration would be mostly the same, so it'll be easier to move the site to a new install.


----------



## IPTRACE (Oct 26, 2016)

I prefer to use nginx for all my services.


----------



## spag (Oct 27, 2016)

Symfony 1.4 has problems with php55 and you set up php70. Did you checked requirements before migration?


----------



## IPTRACE (Oct 27, 2016)

No. I migrated with some code changes and all works fine except one thing described in this thread.
I always use up to date apps knowing that some problems could occurred.


----------

