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

[8.x] Trusted Proxies From Config File #7457

Closed
wants to merge 1 commit into from
Closed

[8.x] Trusted Proxies From Config File #7457

wants to merge 1 commit into from

Conversation

rrpadilla
Copy link

No description provided.

Trusted Proxies From Config File
@taylorotwell
Copy link
Member

I would need to revisit this and format it better. Is there a reason why you want to do this?

@rrpadilla
Copy link
Author

@taylorotwell This is very helpful when your local development is sail or laravel homestead but your production site is hosted on AWS behind a load balancer. The best use case for this is to get the values form a config file.

The current TrustProxies middleware is base on the TrustedProxies package by Chris Fidao and that package is using a config file.

This is a nice guide for any developer that still have to use the config file.

You can read more about this here.

Thanks.

@mtb3
Copy link

mtb3 commented Jan 21, 2022

For what it's worth, I agree that this could be a useful addition to the documentation. In particular, for developers coming from older / existing Laravel applications (that are / were using the previous external TrustedProxies package), it can be initially confusing why a config file is not used.

schu added a commit to openmultiplechoice/openmultiplechoice that referenced this pull request May 6, 2023
Laravel's `url(...)` helper has the habit to return `http://...` URLs
and to disregard the configured `APP_URL` if the reverse proxy does use
http and if `X-Forwarded-Proto` is not set or trusted. Add
`config/trustedproxies.php` to allow users to trust proxies.

For some reason this approach is not documented in the official docs but
appears to be "the right way":

https://laravel.com/docs/10.x/requests#configuring-trusted-proxies
laravel/docs#7457
https://github.com/laravel/framework/blob/10.x/src/Illuminate/Http/Middleware/TrustProxies.php

Resolves #556
schu added a commit to openmultiplechoice/openmultiplechoice that referenced this pull request May 6, 2023
Laravel's `url(...)` helper has the habit to return `http://...` URLs
and to disregard the configured `APP_URL` if the reverse proxy does use
http and if `X-Forwarded-Proto` is not set or trusted. Add
`config/trustedproxy.php` to allow users to trust proxies.

For some reason this approach is not documented in the official docs but
appears to be "the right way":

https://laravel.com/docs/10.x/requests#configuring-trusted-proxies
laravel/docs#7457
https://github.com/laravel/framework/blob/10.x/src/Illuminate/Http/Middleware/TrustProxies.php

Resolves #556
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

Successfully merging this pull request may close these issues.

3 participants