- 設定 Nginx Web Server,架設 Reverse Proxy Server 服務!
事前準備:
- 請先參考這一篇文件,架設好 Nginx Web Server!
快速設定流程:
-
編寫 Nginx 預設設定檔:
#vi /etc/nginx/nginx.conf (註解以下設定:) # server { : : # }
-
編寫 for proxy 的設定檔:
#vi /etc/nginx/conf.d/proxy.conf upstream proxy { server 192.168.5.61:80; } server { listen 80 default; server_name www.example.com; access_log /var/log/nginx/jenkins.access.log; error_log /var/log/nginx/jenkins.error.log; proxy_buffers 16 64k; proxy_buffer_size 128k; location / { proxy_pass http://proxy; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; } }
-
啟動 Nginx :
#systemctl enable nginx.service #systemctl start nginx.service
-
啟動防火牆:
#firewall-cmd --permanent --add-service=http #firewall-cmd --reload
參考文獻:
- https://www.nginx.com/resources/admin-guide/reverse-proxy/
- http://shazi.info/centos-6-%E5%BB%BA%E7%AB%8B-nginx-reverse-proxy/
- https://www.twstar.biz/43151.html
- http://icodding.blogspot.tw/2015/08/nginx.html
- https://snippetinfo.net/media/671/
- https://deviantengineer.com/2015/05/nginx-reverseproxy-centos7/
- https://www.rosehosting.com/blog/install-and-configure-jenkins-with-nginx-as-a-reverse-proxy-on-centos-7/