日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

nginx测试小结

發布時間:2025/4/16 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nginx测试小结 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近在工作當中需要使用nginx,就對nginx進行進一步的了解,測試。

工作需求是在微服務架構的基礎上,客戶端通過nginx反向代理訪問服務端,確保當一個服務端出現問題時能及時切換到正常工作的服務端。測試使用nginx-1.13.2.rar,官網地址為:http://www.nginx.org/;測試使用的ip服務端為:10.74.214.109:8088、10.74.214.109:8091,服務端啟動時的端口為8090;程序首頁的路徑為:"D:\cloudCode\internet\CoreToolWebPortal\01.CoreToolWebPotalWeb"下的index.html文件 將nginx解壓包放在C盤根目錄下: 編輯修改nginx.conf文件,如下: #Nginx用戶組。windows下不指定; #user ?nobody; ? ?????#工作進程:數目。根據硬件調整,通常等于CPU數量,或者2倍于CPU; ?????worker_processes ?1; ? ?????#pid ???????logs/nginx.pid; ? ? ???events { ????????#每個工作進程的最大連接數量,根據硬件調整,和前面工作進程配合起來使用,盡量大, ????????#但是別把CPU跑到100%就行。 ????????#每個進程允許的最多連接數,理論上沒臺nginx服務器的最大連接數 ?????? ????????#為:worker_process*worker_connections ???????worker_connections ?1024; ???????} ? ???????#設定http服務器,利用它的反向代理功能提供負載均衡支持 ???????http { ???????????# 設定mime類型,類型由mime.type文件定義 ???????????include ??????mime.types; ???????????default_type ?application/octet-stream; ? ???????????#log_format ?main ?'$remote_addr - $remote_user [$time_local] "$request" ' ???????????# ?????????????????'$status $body_bytes_sent "$http_referer" ' ???????????# ?????????????????'"$http_user_agent" "$http_x_forwarded_for"'; ? ???????????#access_log ?logs/access.log ?main; ? ???????????sendfile ???????on; ???????????#tcp_nopush ????on; ? ???????????#keepalive_timeout ?0; ???????????keepalive_timeout ?65; ? ???????????#gzip ?on; ? ???????????#負載均衡地址 ???????????upstream ?api_server{ ?????????????????#server 10.74.214.109:8091 weight=1 max_fail=3 fail_timeout=30; ?????????????????server ??10.74.214.109:8091; ?????????????????server ??10.74.214.109:8088 backup;#熱備 ???????????} ? ???????????server { ?????????????????listen ??????8090;#備注:啟動服務器的端口為這個; ? ?????????????????#配置訪問域名 ?????????????????server_name ?localhost; ? ?????????????????#charset koi8-r; ? ?????????????????#access_log ?logs/host.access.log ?main; ? ?????????????????location / { ?????????????????root ?"D:\cloudCode\internet\CoreToolWebPortal\01.CoreToolWebPotalWeb"; ?????????????????index ?index.html index.htm; ??????????} ? ????????#error_page ?404 ?????????????/404.html; ? ????????# redirect server error pages to the static page /50x.html ????????# ????????error_page ??500 502 503 504 ?/50x.html; ????????location = /50x.html { ????????????root ??html; ????????} ? ????????# proxy the PHP scripts to Apache listening on 127.0.0.1:80 ????????# ????????#location ~ \.php$ { ????????# ???proxy_pass ??http://127.0.0.1; ????????#} ? ????????# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 ????????# ????????#location ~ \.php$ { ????????# ???root ??????????html; ????????# ???fastcgi_pass ??127.0.0.1:9000; ????????# ???fastcgi_index ?index.php; ????????# ???fastcgi_param ?SCRIPT_FILENAME ?/scripts$fastcgi_script_name; ????????# ???include ???????fastcgi_params; ????????#} ? ????????# deny access to .htaccess files, if Apache's document root ????????# concurs with nginx's one ????????# ????????#location ~ /\.ht { ????????# ???deny ?all; ????????#} ? ? ? ? ????????#實現反向代理 ????????location ~* ^/services/.*{ ?????????????#請求的主機域名 ?????????????proxy_set_header ?Host ?$host; ????????????? ?????????????#轉的目標ip ?? ?????????????proxy_set_header ?X-Real-IP ?$Remote_addr; ? ? ?????????????#轉發的目標 ?????????????proxy_set_header ?X-Forwarded-For $proxy_add_x_forwarded_for; ? ?????????????#禁止緩沖 ?????????????proxy_buffering ?off; ? ?????????????#代理地址 ?????????????proxy_pass ??http://api_server; ? ???????} ????} ? ? ????# another virtual host using mix of IP-, name-, and port-based configuration ????# ????#server { ????# ???listen ??????8000; ????# ???listen ??????somename:8080; ????# ???server_name ?somename ?alias ?another.alias; ? ????# ???location / { ????# ???????root ??html; ????# ???????index ?index.html index.htm; ????# ???} ????#} ? ? ????# HTTPS server ????# ????#server { ????# ???listen ??????443 ssl; ????# ???server_name ?localhost; ? ????# ???ssl_certificate ?????cert.pem; ????# ???ssl_certificate_key ?cert.key; ? ????# ???ssl_session_cache ???shared:SSL:1m; ????# ???ssl_session_timeout ?5m; ? ????# ???ssl_ciphers ?HIGH:!aNULL:!MD5; ????# ???ssl_prefer_server_ciphers ?on; ? ????# ???location / { ????# ???????root ??html; ????# ???????index ?index.html index.htm; ????# ???} ????#} ? ? ? } 運行nginx:cmd->cd ../..->cd nginx-1.13.2->start nginx.exe 由于時在公司測試的運行,公司出于保密需要截圖不允許外發,暫不將測試的截圖貼上,敬請諒解!

轉載于:https://www.cnblogs.com/ITBlock/p/9886469.html

總結

以上是生活随笔為你收集整理的nginx测试小结的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。