Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pantheon Drupal8 missing fastcgi_param PATH_INFO #18

Closed
woodseowl opened this issue Feb 19, 2020 · 7 comments
Closed

Pantheon Drupal8 missing fastcgi_param PATH_INFO #18

woodseowl opened this issue Feb 19, 2020 · 7 comments
Assignees

Comments

@woodseowl
Copy link

Using Lando v3.0.0-rc.23 with Pantheon Drupal 8...

I'm finding that PATH_INFO isn't defined in the server environment variable but there is a line in the pantheon/drupal8.conf.tpl file that suggests it is expected to be:
https://github.com/lando/lando/blob/6a37c0912104861684be3346fa60de76abf38cbc/plugins/lando-pantheon/recipes/pantheon/drupal8.conf.tpl#L154

Based on nginx's documentation, the PATH_INFO param needs to be explicitly set:
http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_split_path_info

This is coming to the surface because simplesamlphp 1.18 made a change in how it gets PATH_INFO and the latest drupal/simplesamlphp_auth (v3.2) has recently incorporated that.

I tested locally by running Lando from source and adding the recommended line from the nginx documentation after each of the three fastcgi_split_path_info settings:

        fastcgi_param PATH_INFO $fastcgi_path_info;

This fixed the missing PATH_INFO server env variable.

I tried a couple of ways just to set this value through local custom config files (a la https://docs.lando.dev/config/nginx.html#configuration or https://docs.lando.dev/config/pantheon.html#configuration) but couldn't seem to get it to take in this Pantheon D8 setup. It was too much black box experimentation at that point to really try to find it, but I would love to know how to make that work.

@dustinleblanc
Copy link

Interestingly, I just reviewed the nginx config on one of my Pantheon Drupal sites by doing this:

  1. lando terminus connection:info localdevux.dev --field=sftp_command
  2. use the provided sftp command to sftp to pantheon
  3. run get nginx.conf and then exit
  4. Run vim nginx.conf to look at the nginx config file from Pantheon.
  5. do a search for PATH_INFO in the file

It looks like Pantheon's path info handling more or less matches ours, I grepped for fastcgi_param PATH in the file and didn't find anything, so I am wondering if Pantheon set's this value a different way (in the prepend script maybe?)

@woodseowl
Copy link
Author

You have an interesting perspective on it, Dustin, since you know Lando and Pantheon rather well. Even with the insight that Pantheon's own configuration does not visibly set the PATH_INFO param, the stated goal of the documentation line seems to be to get simplesamlphp to function in a local environment:
https://github.com/lando/lando/blob/6a37c0912104861684be3346fa60de76abf38cbc/plugins/lando-pantheon/recipes/pantheon/drupal8.conf.tpl#L154
With that being the case, and looking at nginx pathinfo documentation and simplesamlphp's new dependency on the PATH_INFO environment variable, it seems like this should be included at least in all of the pantheon Drupal recipes.

@dustinleblanc
Copy link

Doing a bit more research via SFTP, the prepend.php file includes '/srv/includes/pantheon.php' and snooping around the /srv/includes folder, there is a fastcgi_params file that includes some PATH_INFO magic:

  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  REQUEST_URI        $request_uri;
  fastcgi_param  DOCUMENT_URI       $document_uri;
  fastcgi_param  DOCUMENT_ROOT      $document_root;
  fastcgi_param  SERVER_PROTOCOL    $server_protocol;

  fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
  fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

  fastcgi_param  REMOTE_ADDR        $remote_addr;
  fastcgi_param  REMOTE_PORT        $remote_port;
  fastcgi_param  SERVER_ADDR        $server_addr;
  fastcgi_param  SERVER_PORT        $server_port;
  fastcgi_param  SERVER_NAME        $hostname;

  # PHP only, required if PHP was built with --enable-force-cgi-redirect
  fastcgi_param  REDIRECT_STATUS    200;

  # Pantheon params

  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

  # Set the REMOTE_ADDR as the client IP so as to not confuse drupal.
  # x-pantheon-client-ip comes from styx but will be missing
  # if requests come directly to nginx
  fastcgi_param REMOTE_ADDR $http_x_pantheon_client_ip;

  # Set HTTPS to the value of User-agent-HTTPS, 'on' or 'off'
  fastcgi_param HTTPS $http_user_agent_https if_not_empty;

It looks to me that we just load this file from our global nginx service and we can make a tweak there

@woodseowl
Copy link
Author

Nice snooping!

dustinleblanc referenced this issue in lando/lando Mar 27, 2020
This is done on Pantheon and seems to be needed for the latest versions
of SimpleSaml. Researching these params for NGINX in general, it seems
these values are actually set by default:

@see https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/
@pirog
Copy link
Sponsor Member

pirog commented Apr 1, 2020

@woodseowl ive got @dustinleblanc's worked queued up in another branch, ready to be merged into master.

This at least seems to define _keys_in $_SERVER for PATH_INFO and PATH_TRANSLATED but like you i could not get PATH_INFO to actually have a value. That said, i can't seem to get it to have a value on Pantheon either so perhaps the existence of the key is sufficient.

This will be in the next release but will require lando rebuild on existing sites. I'm also going to close this out for now but let's reopen if it turns out we need to do more than get the param to exist.

@pirog pirog closed this as completed Apr 1, 2020
@woodseowl
Copy link
Author

@pirog I just tested locally with these commits and it works great now. Thanks!

@pirog
Copy link
Sponsor Member

pirog commented Apr 1, 2020

Oh very nice! Great to have confirmation from projects running in the wild

@rtfm-47 rtfm-47 transferred this issue from lando/lando Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants