403 forbidden after switching from Apache to NGINX

SYSTEM INFORMATION
OS type and version Ubuntu Linux 24.04.3
Virtualmin version 7.30.8

Hello.

I just switched my web Server from Apache to NGINX by following these instructions here: https://www.virtualmin.com/docs/server-components/configuring-nginx-as-default-webserver/#switching-from-nginx-to-apache .

But, after that, I’m getting 403 Forbidden on my LARAVEL App which hosted on the same Server:

Knowing that was working or running very well when I was on Apache but not now since I switch to NGINX.
PLEASE, Help me to fix this problem.

Awaiting your help.

Are your logs showing anything?

Here is the Logs:

2025/09/05 19:40:13 [error] 3383180#3383180: *64 open() "/home/our-domain/public_html/login" failed (2: No such file or directory), client: 102.67.213.165, server: our-domain.com, request: "GET /login HTTP/1.1", host: "our-domain.com"
2025/09/05 19:38:42 [error] 3383180#3383180: *61 open() "/home/our-domain/public_html/login" failed (2: No such file or directory), client: 102.67.213.165, server: our-domain.com, request: "GET /login HTTP/1.1", host: "our-domain.com"
2025/09/05 19:37:23 [error] 3383181#3383181: *57 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 19:36:27 [error] 3383181#3383181: *57 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 19:36:26 [error] 3383181#3383181: *57 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 19:36:25 [error] 3383181#3383181: *57 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 19:36:24 [error] 3383181#3383181: *57 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 19:36:21 [error] 3383181#3383181: *57 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 19:32:12 [error] 3383183#3383183: *54 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 19:30:48 [error] 3383182#3383182: *53 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 19:30:45 [error] 3383182#3383182: *53 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 18:56:35 [error] 3367940#3367940: *40 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 18:53:07 [error] 3367937#3367937: *35 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 18:36:56 [error] 3353318#3353318: *21 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 18:36:53 [error] 3353318#3353318: *21 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 18:36:50 [error] 3353318#3353318: *21 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 18:21:32 [error] 3353318#3353318: *1 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 18:12:22 [error] 3343407#3343407: *8 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 18:12:17 [error] 3343407#3343407: *8 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 18:05:58 [error] 3343406#3343406: *4 directory index of "/home/our-domain/public_html/" is forbidden, client: 102.67.213.165, server: our-domain.com, request: "GET / HTTP/1.1", host: "our-domain.com"
2025/09/05 18:05:48 [error] 3343406#3343406: *4 open() "/home/our-domain/public_html/favicon.ico" failed (2: No such file or directory), client: 102.67.213.165, server: our-domain.com, request: "GET /favicon.ico HTTP/1.1", host: "our-domain.com", referrer: "https://our-domain.com/login"
2025/09/05 18:05:48 [error] 3343406#3343406: *4 open() "/home/our-domain/public_html/login" failed (2: No such file or directory), client: 102.67.213.165, server: our-domain.com, request: "GET /login HTTP/1.1", host: "our-domain.com"
2025/09/05 18:03:22 [error] 3343399#3343399: *1 directory index of "/home/our-domain/public_html/" is forbidden, client: 91.84.109.110, server: our-domain.com, request: "GET / HTTP/1.1", host: "OUR-DOMAIN.COM"

I should point out that in my .htaccess file, which I used since I was still using Apache before migrating to NGINX, I have the following content:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Doesn’t look like there’s any proxying to PHP-FPM going on there. Are you sure you really did everything you need to do to switch from Apache to nginx? Looks like it’s trying to serve files directly from the file system.

that was nginx to apache! you are trying to go Apache to Nginx do remember that Nginx is quite a different webserver just as much as Laravel is more than simple PHP.

Nginx knows nothing about .htaccess

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.