Allow HTTP for one route only
Hi
Is it possible to update the Nginx file to allow a port 80 url for one route only, keeping the rest via 443?
I'm using the LetsEncrypt certificate installation via Laravel Forge.
Thanks
Chris
Could you start by explaining why this is needed? Perhaps there is a better way :)
Hardware that does not support port ssl will call this endpoint
@chrismerron what I would do instead is to allow port 80 and 443 to be accessible on your nginx and edit your AppServiceProvider like this:
public function boot()
{
if($this->app->request->getRequestUri() != '/my-http-route') {
URL::forceSchema('https');
}
}
And don't forget to import the URL class :)
Just be aware that this will allow static content to be served over http as well then :) Maybe not a problem, but just informing you of it :)
This solution will work, but perhaps it's better via the server and Nginx?
Agree with @sinnbeck
@chrismerron maybe you can share why you need this one route to be served on HTTP in the first place?
Yep, it's a limitation of hardware that call this route that do not support HTTPs
Can you post your current nginx config for the site?
how about this:
# http
server {
listen 80;
#other configs here
location / {
rewrite ^ https://$host$request_uri? permanent;
}
location /my-route {
}
}
# https
server {
listen 443;
#other configs here
location / {
}
location /my-route {
rewrite ^ http://$host$request_uri? permanent;
}
}
I can't link to it it as I'm not allowed to include links the first day I sign up :(
Don't forget to mark it as the best answer if this fixes your problem ;) Thanks @chrismerron
Please or to participate in this conversation.