octobercms / october

Self-hosted CMS platform based on the Laravel PHP Framework.
https://octobercms.com/
Other
11.02k stars 2.21k forks source link

Help with 502 Bad Gateway Error in October CMS #5813

Closed lbz303 closed 2 months ago

lbz303 commented 3 months ago

Question Content: I have installed October CMS on CentOS 7 and am using Nginx as a reverse proxy. I am encountering a 502 Bad Gateway error when trying to access the admin panel via a public IP.

Environment Information:

Operating System: CentOS 7 Nginx Version: 1.20.1 PHP Version: 8.0.30 October CMS Development Server: Running on 127.0.0.1:9092 Configuration File:

The Nginx configuration file is as follows:

nginx server { listen 9001;

location / {
    proxy_pass http://127.0.0.1:9092;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

} Behavior Observed:

When accessing http://117.72.95.12:9001/admin, I am redirected to:

http://117.72.95.12/admin/backend/auth, which returns a 502 Bad Gateway error. The Nginx logs show the following error: 2024/08/02 19:27:28 [error] 9147#9147: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 27.151.43.174, server: _, request: "GET /admin HTTP/1.1", upstream: "http://127.0.0.1:9092/admin", host: "117.72.95.12:9001" Request for Help:

How can I fix the redirection issue that leads to the 502 Bad Gateway error? Is there a specific configuration I should use in Nginx to properly handle these redirects for October CMS?

daftspunk commented 3 months ago

Hi @lbz303

Here are some links that you may find useful:

I'm unsure why the URL is losing its port number, this shouldn't happen.