Khi b?n tìm ki?m và th?y bài vi?t này thì ch?c h?n b?n ?ã bi?t tác d?ng c?a vi?c dùng Nginx làm proxy. Nghe thì có v? r?c r?i nh?ng làm thì l?i r?t d? và nhanh. Bài vi?t này s? h??ng d?n cài ??t Nginx làm proxy trên Centos Linux theo cách d? dàng nh?t
Cài ??t Nginx trên Centos Linux
yum install epel-release -y
yum install nginx -y
systemctl start nginx
systemctl enable nginx
C?u hình Nginx làm proxy trên Centos Linux
Dùng trình so?n th?o vi m? file config c?a nginx:
vi /etc/nginx/conf.d/domain.conf
server {
listen 80;
server_name yourdomain.pro www.yourdomain.pro;
location / {
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;
proxy_pass http://xxx.xxx.xxx.xxx/;
proxy_redirect off;
}
}
(thay yourdomain.pro b?ng tên mi?n c?a b?n, thay xxx.xxx.xxx.xxx b?ng ip main server c?a b?n)
Ch?y l?i nginx ?? nh?ng thay ??i có tác d?ng
systemctl restart nginx
done