Nginx Configuring HTTPS Forward HTTP, WebSocket

After the system starts Nginx, it reports [emerg] bind() to 0.0.0.0:XXXX failed (13: Permission denied). There are two ways to handle the error:

The first type: the case where the port is less than 1024: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
The reason is that the port below 1024 requires root permission to start, so sudo nginx is enough.

The second type: the case where the port is greater than 1024: [emerg] bind() to 0.0.0.0:8380 failed (13: Permission denied)
In this case, you need to do the following: First, check http allowed access port: semanage port -l | grep http_port_t
http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000
Next, add the port to be started to the semanage port list above -a -t http_port_t -p tcp 8090

———————— ————————————–
http forwarding
server
{
listen 88;
server_name www.xxx.net;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;< br> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8888;
}
access_log logs/xxx.net_access.log main;


—————————————— —
websock forwarding
server {
listen 4343 ssl http2 default_server;
listen [::]:4343 ssl http2 default_server;
server_name game.geeeagle.com;
root /usr/share/nginx/html;

ssl_certifica te “/etc/nginx/cert/game.geeeagle.com.pem”;
ssl_certificate_key “/etc/nginx/cert/game.geeeagle.com.key”;
ssl_session_cache shared:SSL:1m;< br> ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

# Load configuration files for the default server block.
include /etc/nginx/default. d/*.conf;

location / {
proxy_pass http://0.0.0.0:8089$request_uri;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
root html;
index index.html index.htm;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

 

Reference original: https://blog.csdn.net/runsnail2018/article/details/81185138

Reference original: https://blog.csdn.net/hzw2312/article/details/51789920

Leave a Comment

Your email address will not be published.