Welcome! Log In Create A New Profile

Advanced

nginx reverse proxy configuration

Posted by naseweis 
nginx reverse proxy configuration
January 30, 2024 10:39AM
Hey Guys,

i have a Nginx Front End Server running on Centos9 on 10.0.100.6 and different docker Containers in the backend.

The docker container working fine i can acess them ez via port number BUT my nginx reverse Proxy configuration not working and i get this red site 500 alarm which saying Site temporally unavailable.

My configuration looks like this ( I just using http because this is just for demonstration/testing) :

server {
listen 80;
listen [::]:80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

location /nextcloud {
proxy_pass http://10.0.100.6:8080/;
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;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

Can you help me with this? I'm realy stuck here!

THX
Re: nginx reverse proxy configuration
February 08, 2024 08:00PM
The root cause of the "500 Internal Server Error" in your NGINX reverse proxy setup is likely due to a misconfiguration or communication issue between NGINX and your backend Docker container. Common causes include:

Incorrect proxy_pass URL or port mismatch with the backend service.
Backend service not running or not reachable at the specified IP and port.
SELinux or firewall blocking the connection between NGINX and the Docker container.
Missing or incorrect headers in the NGINX configuration that are required by the backend application.
Check these areas to identify and resolve the specific cause in your setup.
Re: nginx reverse proxy configuration
February 08, 2024 08:01PM
To address the root causes identified, follow these steps to potentially fix the "500 Internal Server Error" in your NGINX reverse proxy setup:

Verify Backend Service:

Ensure the Docker container for your backend service (e.g., Nextcloud) is running and accessible at 10.0.100.6:8080. Use curl http://10.0.100.6:8080 or access this URL from a browser on the same network to confirm.
Correct NGINX Configuration:

Update the proxy_pass directive to match the exact endpoint of your backend service. If the service is directly at 10.0.100.6:8080, use proxy_pass http://10.0.100.6:8080; without a trailing slash.
Ensure the rest of the proxy settings are correct and compatible with your backend service requirements.
SELinux Configuration:

Temporarily set SELinux to permissive mode with sudo setenforce 0 and retry accessing the service. If this fixes the issue, use the audit2allow tool to analyze SELinux logs and create a new policy module to allow the required connections, instead of leaving SELinux disabled.
Adjust Firewall Settings:

Check and adjust your firewall settings to allow traffic from NGINX to your Docker containers. If using firewall-cmd, you might need to add a rule to allow connections to the specific port your backend service is running on.
Review NGINX Logs:

Check /var/log/nginx/error.log for specific error messages that could indicate the exact problem. Address any errors or warnings found here.
Reload NGINX Configuration:

After making changes to your NGINX configuration, reload the service to apply the changes. Use sudo nginx -t to test the configuration for syntax errors, then sudo systemctl reload nginx to apply changes.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 201
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready