I installed nginx on a recently installed Alma Linux 9 system.
After starting the updates with sudo yum update -y
I reviewed the initial configuration of nginx to be able to build a node application that runs on port 9999
nginx.config
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pidlogs/nginx.pid;
events {
worker_connections 1024;
}
http {
includemime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
#'$status $body_bytes_sent "$http_referer" '
#'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfileon;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404/404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ .php$ {
# roothtml;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# includefastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen8000;
# listensomename:8080;
# server_name somename alias another.alias;
# location / {
#root html;
#index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
#root html;
#index index.html index.htm;
# }
#}
}
just before the first server configuration I call the file that contains the reverse proxy
include /etc/nginx/config.d/elchanchoganador.config
following the steps in the documentation
https://www.server-world.info/en/note?os=AlmaLinux_9&p=nginx&f=8&fbclid=IwZXh0bgNhZW0CMTAAAR37cuAKNirKbY3qwBLXmYb1xBrFGXnX2gei0Qu5Vxkp2MTqIMRRELTY76k_aem_AQPuZJAjlAW1tLGfqFh3QaKJNa55hl_E5y4Pij3XbsJIsRKqTo_0uXDwE1zCKOm25hLW2Tts_Y37EgWRhSO_aWyw
server {
listen 80;
listen [::]:80;
#listen 443 ssl http2; #NO SSL
#listen [::]:443 ssl http2;
server_name elchanchoganador.com www.elchanchoganador.com;
#ssl_certificate "/etc/letsencrypt/live/rx-7.srv.world/fullchain1.pem";
#ssl_certificate_key "/etc/letsencrypt/live/rx-7.srv.world/privkey1.pem";
#ssl_session_cache shared:SSL:1m;
#ssl_session_timeout 10m;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
location / {
proxy_pass http://127.0.0.1:9999/;
}
}
reboot the system with
sudo systemctl restart nginx
sudo systemctl reload nginx
and does not show errors when using
nginx -t
but when I enter the domain I get the index page
I want to be able to redirect everything I have on port 9999 to port 80, enter my domain without ports
http://elchanchoganador.com:9999/ node app
http://elchanchoganador.com/ => show node app content
Chaoticsystem504 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.