Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chrismerron's avatar

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

0 likes
13 replies
Sinnbeck's avatar

Could you start by explaining why this is needed? Perhaps there is a better way :)

chrismerron's avatar

Hardware that does not support port ssl will call this endpoint

neilstee's avatar

@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');
        }
}
neilstee's avatar

And don't forget to import the URL class :)

Sinnbeck's avatar

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 :)

1 like
chrismerron's avatar

This solution will work, but perhaps it's better via the server and Nginx?

chrismerron's avatar

Yep, it's a limitation of hardware that call this route that do not support HTTPs

Sinnbeck's avatar

Can you post your current nginx config for the site?

neilstee's avatar

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;
    }
}
chrismerron's avatar

I can't link to it it as I'm not allowed to include links the first day I sign up :(

Please or to participate in this conversation.