Use nginx as a reverse proxy

mar

bitcoin is freedom
Staff member
Joined
Jan 14, 2015
Messages
170
Points
28
Credits
55,526,874
Bronze Usergroup
Username Style
Here is a good video on using nginx as a reverse proxy



1. sudo yum install epel-release
2. yum install nginx
3. sudo systemctl start nginx.service
4. sudo firewall-cmd --permanent --zone=public --add-service=http
5. sudo firewall-cmd --permanent --zone=public --add-service=https
6. sudo systemctl enable nginx.service
7. change hostname /etc/hostname
example myserver
8. hosts file /etc/hosts add
example 192.168.1.108 localhost.localdomain website1.com website2.com
9. configure /etc/nginx/nginx.conf

Code:
# For more information on configuration, see:
#  * Official English Documentation: http://nginx.org/en/docs/
#  * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
  worker_connections 1024;
}

http {
  server {
  listen 80;
  server_name website1.com;
  location  /  {
  proxy_set_header  x-real-IP  $remote_addr;
  proxy_set_header  x-forwarded-for  $proxy_add_x_forwarded_for;
  proxy_set_header  host  $host;
  proxy_pass  http://192.168.1.110;
  }
 
  }
}



10. restart sudo systemctl restart nginx.service




that's it, for a second vm server, just add the same http inside the same file



done!
 
The Biggest Forums - The Biggest, Largest, Best, Most Popular Forums and Message Boards Top List on the Internet.
The Biggest Forums - The Biggest, Largest, Best, Most Popular Forums and Message Boards Top List on the Internet. Forum-List.com

Number of visitors since November 2018: