I think this module is not necessary at all. Ngrok behaves like a reverse proxy and Drupal 8 supports reverse proxies out of the box.
All you have to do is to configure the reverse proxy correctly. Unfortunately, the X_FORWARDED_HOST is not set correctly by Ngrok, so you have to fix this first in a .htaccess file.
-
Fix X_FORWARDED_HOST in .htaccess file
# Handle ngrok X-Original-Host Header
RewriteCond %{HTTP:X-Original-Host} \.ngrok\.io$ [NC]
RewriteRule .* - [E=HTTP_X_FORWARDED_HOST:%{HTTP:X-Original-Host}]
-
Reverse Proxy settings in settings.php
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = ['127.0.0.1', '::1','your ip'];
These two simple steps will unlock cookie handling, URL support, and so on. Maybe you could add these steps as module documentation instead because a lot of people land on the module page from search engines.
Comments
Comment #2
Marko B commentedAbandoning the module???!!! NEVER!!! :)))
Joking of course, well I would need to try this, would be nice also to have NGINX config for this as most people will use that today. Would be glad if this is the case and we can just config it to work.
Comment #3
Marko B commentedComment #4
vlad.dancerI'm not sure that "Consider abandoning the module because Drupal 8 support reverse proxies out of the box" is a good option.
There are lot of cases when it is necesarry to change more configuration to make drupal instance work with ngrok.
An example
@Marko B, regarding nginx conf I'm using this additional one:
add_header X-Forwarded-Host $http_x_original_host;and then in code:
This is required in our case, we are using drupal inside docker container and want to share it outside of localhost.
We are using Traefik as reverse proxy to the docker drupal container and nginx as webserver inside docker stack, so we need to pass original host to the drupal.
Comment #5
lamp5@ayalon thx for this issue. It helps to configure google apis and authenticate app using Oauth 2.0
Comment #6
lpeabody commentedEither I'm not understanding how to use the various reverse proxy settings together, or, regardless of how correctly I have them configured this isn't working for me. I'm trying to test an OpenID Connect authentication mechanism, and in order to preserve the state value in the session that gets generated during the initial handshake I had to set the cookie domain like in the Drupal Answers example https://drupal.stackexchange.com/questions/233750/how-to-setup-cookie-do....
So ultimately I agree with this issue title, with decent documentation this module is mostly not needed.
Comment #7
baluertlComment #8
baluertl@ayalon thank you for sharing this piece of advice, it did the trick for me also! Now I can login my locally run site through Tor network.
Comment #9
marijan gudelj