鐢╪ginx鍋氫唬鐞嗘湇鍔″櫒涓婄綉
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鐢╪ginx鍋氫唬鐞嗘湇鍔″櫒涓婄綉相关的知识,希望对你有一定的参考价值。
鏍囩锛?/p>
鐩墠鐜扮姸锛氬彧鏈?涓満鍣ㄨ兘涓婄綉(web),鍏朵粬鏈哄櫒涓嶈兘
鏂规硶锛氳兘涓婄綉鐨勫仛涓€涓唬鐞唚eb鏈嶅姟鍣ㄤ腑杞紝鍏朵粬鏈哄櫒杩炴帴瀹冨嵆鍙€傞噰鐢╪ginx
Nginx閰嶇疆濡備笅锛?br />
server{
resolver x.x.x.x;
listen 82;
location / {
proxy_pass http://$http_host$request_uri;
}
}
娉ㄦ剰椤癸細
1. 涓嶈兘鏈塰ostname
2. 蹇呴』鏈塺esolver, 鍗砫ns锛屽嵆涓婇潰鐨剎.x.x.x锛屾崲鎴愪綘浠殑DNS鏈嶅姟鍣╥p鍗冲彲
3 . $http_host鍜?request_uri鏄痭ginx绯荤粺鍙橀噺锛屼笉瑕佹兂鐫€鏇挎崲浠栦滑锛屼繚鎸佸師鏍峰氨OK銆?br />
鏌ョ湅dns鏂规硶
cat /etc/resolv.conf
浠g悊浣跨敤
鍦ㄩ渶瑕佽闂缃戠殑鏈哄櫒涓婃墽琛屼互涓嬫搷浣滀箣涓€鍗冲彲锛?br />1. export http_proxy=http://yourproxyaddress锛歱roxyport
2. gedit ~/.bashrc
export http_proxy=http://yourproxyaddress锛歱roxyport
yourproxyaddress涔熷氨鏄綘鐨凬ginx鏈嶅姟鍣ㄧ殑ip浜嗭紝proxyport灏辨槸涓婇潰閰嶇疆涓殑82锛屽彲浠ユ牴鎹嚜宸辩殑闇€瑕佷慨鏀广€?br />
涓句緥锛?br />
鏂规硶锛氳兘涓婄綉鐨勫仛涓€涓唬鐞唚eb鏈嶅姟鍣ㄤ腑杞紝鍏朵粬鏈哄櫒杩炴帴瀹冨嵆鍙€傞噰鐢╪ginx
Nginx閰嶇疆濡備笅锛?br />
server{
resolver x.x.x.x;
listen 82;
location / {
proxy_pass http://$http_host$request_uri;
}
}
娉ㄦ剰椤癸細
1. 涓嶈兘鏈塰ostname
2. 蹇呴』鏈塺esolver, 鍗砫ns锛屽嵆涓婇潰鐨剎.x.x.x锛屾崲鎴愪綘浠殑DNS鏈嶅姟鍣╥p鍗冲彲
3 . $http_host鍜?request_uri鏄痭ginx绯荤粺鍙橀噺锛屼笉瑕佹兂鐫€鏇挎崲浠栦滑锛屼繚鎸佸師鏍峰氨OK銆?br />
鏌ョ湅dns鏂规硶
cat /etc/resolv.conf
浠g悊浣跨敤
鍦ㄩ渶瑕佽闂缃戠殑鏈哄櫒涓婃墽琛屼互涓嬫搷浣滀箣涓€鍗冲彲锛?br />1. export http_proxy=http://yourproxyaddress锛歱roxyport
2. gedit ~/.bashrc
export http_proxy=http://yourproxyaddress锛歱roxyport
yourproxyaddress涔熷氨鏄綘鐨凬ginx鏈嶅姟鍣ㄧ殑ip浜嗭紝proxyport灏辨槸涓婇潰閰嶇疆涓殑82锛屽彲浠ユ牴鎹嚜宸辩殑闇€瑕佷慨鏀广€?br />
涓句緥锛?br />
- worker_processes 1;
- master_process off;
- daemon off;
- #pid /var/run/nginx.pid;
- events {
- worker_connections 768;
- # multi_accept on;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- log_format main 鈥?remote_addr - $remote_user [$time_local] "$request" 鈥?/li>
- 鈥?status $body_bytes_sent "$http_referer" 鈥?/li>
- 鈥?$http_user_agent" "$http_x_forwarded_for"鈥?
- access_log /var/log/nginx/access.log;
- error_log /var/log/nginx/error.log;
- sendfile on;
- server {
- resolver 10.57.220.2;
- listen 82;
- access_log logs/host.access.log main;
- location / {
- proxy_pass http://$http_host$request_uri;
- }
- }
- }
-
绗?閮ㄥ垎:娴嬭瘯骞跺惎鍔╪ginx
ulimit -SHn 51200
/usr/local/webserver/nginx/sbin/nginx -t
/usr/local/webserver/nginx/sbin/nginx
绗?閮ㄥ垎:nginx鏃ュ織鍒囧壊鑴氭湰
以上是关于鐢╪ginx鍋氫唬鐞嗘湇鍔″櫒涓婄綉的主要内容,如果未能解决你的问题,请参考以下文章