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

Test that app URLs are generated properly in the face of HTTPS #2

Closed
paulproteus opened this issue Apr 26, 2015 · 2 comments
Closed

Comments

@paulproteus
Copy link
Collaborator

@JanJambor discussed with the paperwork team an issue where absolute URLs in Paperwork weren't being generated properly in his Sandstorm package. The problem seemed to be that $_SERVER['https'] needs to be set to on for Paperwork/Laravel to figure things out properly, but that doesn't happen with his nginx etc. setup.

(Full discussion here: paperwork/paperwork#281)

My suggestion is that we should

    1. adjust vagrant-spk's "LEMP" (Linux ENginx MySQL PHP) configuration to handle this on behalf of frameworks, setting $_SERVER['https'] to on if the X-Forwarded-Proto is https. Having said that, I haven't dug into the sandstorm-http-bridge setup enough to find out if that's going to be feasible.
    1. Use absolute CSS URLs in https://github.com/paulproteus/php-app-to-package-for-sandstorm app to be able to test that the handling works properly.

Relevant links:

@paulproteus paulproteus changed the title Test that app URLs are generated in the face of HTTPS Test that app URLs are generated properly in the face of HTTPS Apr 26, 2015
@paulproteus
Copy link
Collaborator Author

For another take, see @drenshaw's WordPress package:

https://github.com/dwrensha/wordpress-sandstorm/blob/2fbe2f9bcdd3782ea577ba1ab69a48944b6b87be/wp-config.php#L26

particularly:

if (isset($headers['X-Sandstorm-Base-Path'])) {
   $sandstorm_base_path = $headers['X-Sandstorm-Base-Path'];
}
if ('https' == substr($sandstorm_base_path, 0, 5)) {
  $_SERVER['HTTPS'] = 'on';
}

I like this a lot.

I also think it should be part of the "Sandstorm vagrant-spk LEMP platform" that it always runs PHP with some environment variable indicating that the app is running within Sandstorm, so that PHP apps can reliably detect if to use their Sandstorm-specific code paths or not, but maybe that's an issue for a separate ticket.

@zarvox
Copy link
Collaborator

zarvox commented May 7, 2015

So, PHP apps can look for _SERVER['HTTP_X_SANDSTORM_BASE_PATH'], which will be present if running under sandstorm, since we'll forward all headers that sandstorm-http-bridge passes on.

I've a patch forthcoming that does the appropriate thing for the embedded nginx, so it php5-fpm has HTTPS set if sandstorm-http-bridge passed on X-Forwarded-Proto: https.

I've tested the CSS absolute path using _SERVER['HTTP_X_SANDSTORM_BASE_PATH'] and it seems to work correctly, so that's also good.

@zarvox zarvox closed this as completed in 64b4d41 May 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants