nginx閰嶇疆鏂囦欢濡備綍閰嶇疆
Nginx鐨勯厤缃枃浠朵綅浜?code>/etc/nginx/nginx.conf銆備笅闈㈡槸涓€浜涘父瑙佺殑閰嶇疆绀轰緥锛?/p>
-
閰嶇疆鐩戝惉鐨勭鍙e彿锛?/p>
http { listen 80; }
-
閰嶇疆铏氭嫙涓绘満锛?/p>
http { server { listen 80; server_name example.com; root /var/www/html; } }
-
閰嶇疆HTTP閲嶅畾鍚戝埌HTTPS锛?/p>
http { server { listen 80; server_name example.com; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name example.com; # 鍏朵粬SSL閰嶇疆 root /var/www/html; } }
-
閰嶇疆浠g悊鏈嶅姟鍣細
http { server { listen 80; server_name example.com; location / { proxy_pass http://backend_server; } } }
杩欏彧鏄竴浜涘父瑙佺殑閰嶇疆绀轰緥锛屼綘鍙互鏍规嵁鑷繁鐨勯渶姹傝繘琛屼慨鏀瑰拰鎵╁睍銆傚畬鎴愰厤缃悗锛屼娇鐢?code>nginx -t鍛戒护妫€鏌ラ厤缃枃浠剁殑璇硶閿欒锛岀劧鍚庝娇鐢?code>nginx -s reload鍛戒护閲嶆柊鍔犺浇閰嶇疆鏂囦欢銆?/p>