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
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!
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!