mixed block HTTPS->HTTP - all ajax calls are via http instead of https
Describe the bug When I try to edit some content using ajax request in administration (for example switch, or delete some entity) I have been blocked via browser.
To Reproduce EasyAdmin 3 version used.
(OPTIONAL) Additional context

I have the same issue using docker because for some reason, symfony thinks my app only serves http (even though I am sure that Nginx is configured properly).
The thing is that EasyAdmin generate absolute urls (with host and scheme) and not relative urls: https://github.com/EasyCorp/EasyAdminBundle/blob/7722c8d9f55a611e2fcb13b16a2b74537a7279c8/src/Router/CrudUrlBuilder.php#L180
I have patched this file to remove UrlGeneratorInterface::ABSOLUTE_URL so that relative urls are generated and I no longer have the issue.
Hi @xaviermarchegay thanks for sharing your solution. It helped me, too.
I am using docker as well, and I think it is well configured.
I don't use Docker, so I can't debug this ... but I'm convinced this has to be some Docker + Symfony issue (or Docker + Nginx, etc.)
I use Symfony local serve to work on my apps, so I can't use HTTP ... everything is HTTPS and I can't see that error. All URLs use HTTPS.
A few days ago, Symfony merged this change related to the profiler: https://github.com/symfony/symfony/pull/31349/files It now generates absolute URLs. Can you please check if this breaks those links to you too? Thanks!
@javiereguiluz Yes, it was actually a simple Symfony configuration issue that I solved a few minutes ago.
@milos-ilic You have to uncomment TRUSTED_PROXIES and TRUSTED_HOSTS in your .env file. Then I added my domain in the host variable and it works perfectly.
@xaviermarchegay Thanks it solved the problem for me !
@javiereguiluz I think you could close this issue because it seems to be a symfony configuration issue.
@javiereguiluz This issue can be reproduced in a scenario: https request -> load balancer:443 -> apache/nginx:80
In above scenario configs for apache/nginx are not aware that they are serving https content. This is very common in aws deployments.
@cvele thanks for the insights ... but we're going to close this issue as recommended by @xaviermarchegay because this looks outside of the scope of this bundle. We use Symfony's asset() to link to all images, CSS and JS files, so I think we're doing all we can do. The rest is Symfony's and others (nginx, AWS, reverse proxies, etc.) responsibility.
@javiereguiluz This issue can be reproduced in a scenario: https request -> load balancer:443 -> apache/nginx:80
In above scenario configs for apache/nginx are not aware that they are serving https content. This is very common in aws deployments.
I have the same issue in aws with load balancer as @cvele said above. Somehow easy admin is generating the links with http not https in the dashboard.
@iulianbeleiu please try to debug the cause of this issue because I don't use that infrastructure. Please, also make sure that the error only happens in EasyAdmin and not in other parts of the Symfony application. Thanks!
@javiereguiluz might be because of end-to-end encryption is not setup. so the load balancer talks with the server instance on port 80, you think this might be the case? The load balancer listens on port 443 tho and also redirects traffic from 80 to 443. When I try to delete a record for example, it redirects to https but then i get redirected to /admin, and the record is not deleted. The Symfony project routes are working fine.
Yes, problem solved. Everything is explained here: https://symfony.com/doc/current/deployment/proxies.html We have to configure Symfony to Work behind a Load Balancer or a Reverse Proxy
Hello,
I have a similar issue with this, unfortunately in my case, the problem only happened on CRUD with AssociationField::new('field')->autocomplete() enabled.
Before using autocomplete, the AssociationField is working. With autocomplete enabled, I cannot fetch the resource because it's blocked (turn out the autocomplete send http request instead of https). Everything else works normally.
My environment: I ran the test app with PHP Built in server (ex: php -S localhost:8088 -t public/), and then use nginx in front of that with valid SSL on port 443 (configured as reverse proxy).
Is there something we need to improve with the AssociationField autocomplete method?
Hello,
It's possible for someone to give a full example please.
My case : https request ->nginx:443 (and 80) -> apache:80 (symfony project)
Thanks
Hi,
I go a similar problem with a reverse proxy pass with path prefix (proxy settings are fine, all x-forwarded headers are correctly used by Symfony 5.2)
MenuItem::linkToCrud works fine but MenuItem::linkToRoute is not handle correctly : "No routes found for /<PREFIX/ my/path/
It turns out that AdminRouterSubscriber::getSymfonyControllerFqcn try to match the external path (with prefix) with the internal one (as declared in Symfony).
I fix the problem by overriding it and using relative URL $url = $this->urlGenerator->generate($routeName, $routeParams, UrlGeneratorInterface::RELATIVE_PATH);, but I hope there's a better solution.
Should I open a new issue ?
To reproduce :
- place your symfony application behind a reverse proxy (apache or traefik with PathPrefix)
- configure it so
<external_url>/<prefix>points to<internal_symfony_url>/ - modify accordingly the conf (https://symfony.com/doc/current/deployment/proxies.html)
- add a MenuItem::linkToRoute item => get the "No routes found" error
I know this is old and closed, but the solution is to set HTTPS=on env var in production deployments.
I know this is old and closed, but the solution is to set
HTTPS=onenv var in production deployments.
I was having this issue with a Docker / Nginx / Php-FPM setup and setting this environment variable fixed it. Thanks @cvele
I did not found any documentation on Symfony about this variable. Do you have some info about it?
@grimabe Sorry, not a lot. I found it while facing the similar issue a while back by stepping.
Again, forcing HTTPS is no the best solution, you should better setup the correct reverse proxy settings, otherwise your application never get the correct remote IP, protocol, prefix or correct hostname
HTTPS=on fixed the issue but you may also consider the ->generateRelativeUrls() option:
- https://github.com/EasyCorp/EasyAdminBundle/issues/5750#issuecomment-1541583581