Fixing nginx “13: Permission Denied” Error on RHEL8 with SELinux
Fix nginx Permission denied when proxying to a non-standard port by adjusting SELinux settings.
When configuring nginx to route traffic to a non-standard port such as 1080 on an instance, you may encounter the error 13: Permission denied. This issue often arises due to SELinux restrictions.
systemd[1]: Starting The nginx HTTP and reverse proxy server...nginx[1626]: nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx[1626]: nginx: [emerg] bind() to 0.0.0.0:1080 failed (13: Permission denied)nginx[1626]: nginx: configuration file /etc/nginx/nginx.conf test failedsystemd[1]: nginx.service: Control process exited, code=exited status=1systemd[1]: nginx.service: Failed with result 'exit-code'.systemd[1]: Failed to start The nginx HTTP and reverse proxy server.Solution
To resolve the issue, you need to allow nginx to use the custom port 1080 by updating SELinux policies. Use the following command:
sudo semanage port -a -t http_port_t -p tcp 1080If you encounter the error sudo: semanage: command not found, install the required package with these commands:
sudo dnf provides /usr/sbin/semanagesudo dnf install policycoreutils-python-utilsRelated posts
Running Proxy.py as a Lightweight HTTP Proxy on EC2
This note describes how to set up Proxy.py, a lightweight HTTP proxy server, on an EC2 instance.
Sign in with Slack Using Cognito User Pools and OIDC
This note describes how to federate Cognito user pools with Slack using OIDC to implement "Sign in with Slack".
Deploying FastAPI on AWS Lambda with Lambda Web Adapter
This example guides you through the process of developing API backends with FastAPI using Lambda Web Adapter.
API Gateway WebSocket: Implementing a Mock Integration
This note describes how to build an API Gateway WebSocket endpoint using mock integration.
Uploading to S3 Through CloudFront Pre-Signed URLs
CloudFront signed URLs let you upload to S3 through a custom domain—useful when direct S3 pre-signed URLs are not an option.
