久久久久久久国产免费看-久久久久久久国产视频-久久久久久久久a免费-久久久久久久久国产-久久久久久久久久爱

搜索
網(wǎng)站建設(shè),網(wǎng)站優(yōu)化,網(wǎng)絡(luò)營銷,app開發(fā),小程序開發(fā),全網(wǎng)營銷

400-825-2717互聯(lián)網(wǎng)開發(fā)&推廣服務(wù)提供商

與我們合作

我們專注:網(wǎng)站策劃設(shè)計、網(wǎng)絡(luò)輿論監(jiān)控、網(wǎng)站優(yōu)化及網(wǎng)站營銷、品牌策略與設(shè)計
主營業(yè)務(wù):網(wǎng)站建設(shè)、移動端微信小程序開發(fā)、APP開發(fā)、網(wǎng)絡(luò)運營、云產(chǎn)品·運維解決方案

有一個品牌項目想和我們談?wù)剢?

您可以填寫右邊的表格,讓我們了解您的項目需求,這是一個良好的開始,我們將會盡快與您取得聯(lián)系。當(dāng)然也歡迎您給我們寫信或是打電話,讓我們聽到您的聲音

您也可通過下列途徑與我們?nèi)〉寐?lián)系:

地 址: 上海市長寧區(qū)華寧國際7L

電 話: 400-825-2717(咨詢專線)

電 話: 13054973230(售后客戶服務(wù))

網(wǎng) 址: http://www.586918.cn

傳 真: 021-61488448

郵 箱: admin@wumujituan.com

快速提交您的需求 ↓

Nginx常用配置

發(fā)布日期:2024-02-26 瀏覽次數(shù):41065

一、基礎(chǔ)配置

  1. user                            root;

  2. worker_processes                1;


  3. events {

  4.   worker_connections            10240;

  5. }


  6. http {

  7.   log_format                    '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent"';

  8.   include                       mime.types;

  9.   default_type                  application/octet-stream;

  10.   sendfile                      on;

  11.   #autoindex                    on;

  12.   #autoindex_exact_size         off;

  13.   autoindex_localtime           on;

  14.   keepalive_timeout             65;

  15.   gzip                          on;

  16.   gzip_disable                  "msie6";

  17.   gzip_min_length               100;

  18.   gzip_buffers                  4 16k;

  19.   gzip_comp_level               1;

  20.   gzip_types                  text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;

  21.   gzip_types                    "*";

  22.   gzip_vary                     off;

  23.   server_tokens                 off;

  24.   client_max_body_size          200m;


  25.   server {

  26.     listen                      80 default_server;

  27.     server_name                 _;

  28.     return                      403 /www/403/index.html;

  29.   }


  30.   include                       ../serve/*.conf;

  31. }

復(fù)制代碼


二、隱藏 Nginx 版本信息

  1. http {

  2.   server_tokens         off;

  3. }

復(fù)制代碼



三、禁止ip直接訪問80端口

  1. server {

  2.   listen                80 default;

  3.   server_name           _;

  4.   return                500;

  5. }

復(fù)制代碼


四、啟動 web 服務(wù) (vue 項目為例)

  1. server {

  2.   # 項目啟動端口

  3.   listen            80;

  4.   # 域名(localhost)

  5.   server_name       _;

  6.   # 禁止 iframe 嵌套

  7.   add_header        X-Frame-Options SAMEORIGIN;

  8.   

  9.   # 訪問地址 根路徑配置

  10.   location / {

  11.     # 項目目錄

  12.     root        html;

  13.     # 默認讀取文件

  14.     index           index.html;

  15.     # 配置 history 模式的刷新空白

  16.     try_files       $uri $uri/ /index.html;

  17.   }

  18.   

  19.   # 后綴匹配,解決靜態(tài)資源找不到問題

  20.   location ~* \.(gif|jpg|jpeg|png|css|js|ico)$ {

  21.     root           html/static/;

  22.   }

  23.   

  24.   # 圖片防盜鏈

  25.   location ~/static/.*\.(jpg|jpeg|png|gif|webp)$ {

  26.     root              html;

  27.     valid_referers    *.deeruby.com;

  28.     if ($invalid_referer) {

  29.       return          403;

  30.     }

  31.   }

  32.   

  33.   # 訪問限制

  34.   location /static {

  35.     root               html;

  36.     # allow 允許

  37.     allow              39.xxx.xxx.xxx;

  38.     # deny  拒絕

  39.     deny               all;

  40.   }

  41. }

復(fù)制代碼


五、PC端和移動端使用不同的項目文件映射

  1. server {

  2.   ......

  3.   location / {

  4.     root /home/static/pc;

  5.     if ($http_user_agent ~* '(mobile|android|iphone|ipad|phone)') {

  6.       root /home/static/mobile;

  7.     }

  8.     index index.html;

  9.   }

  10. }

復(fù)制代碼


六、一個web服務(wù),配置多個項目 (location 匹配路由區(qū)別)

  1. server {

  2.   listen                80;

  3.   server_name           _;

  4.   

  5.   # 主應(yīng)用

  6.   location / {

  7.     root                html/main;

  8.     index               index.html;

  9.     try_files           $uri $uri/ /index.html;

  10.   }

  11.   

  12.   # 子應(yīng)用一

  13.   location ^~ /store/ {

  14.     proxy_pass          http://localhost:8001;

  15.     proxy_redirect      off;

  16.     proxy_set_header    Host $host;

  17.     proxy_set_header    X-Real-IP $remote_addr;

  18.     proxy_set_header    X-Forwarded-For

  19.     proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;

  20.   }

  21.   

  22.   # 子應(yīng)用二

  23.   location ^~ /school/ {

  24.     proxy_pass          http://localhost:8002;

  25.     proxy_redirect      off;

  26.     proxy_set_header    Host $host;

  27.     proxy_set_header    X-Real-IP $remote_addr;

  28.     proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;

  29.   }

  30.   

  31.   # 靜態(tài)資源讀取不到問題處理

  32.   rewrite ^/api/profile/(.*)$ /(替換成正確路徑的文件的上一層目錄)/$1 last;

  33. }


  34. # 子應(yīng)用一服務(wù)

  35. server {

  36.   listen                8001;

  37.   server_name           _;

  38.   location / {

  39.     root                html/store;

  40.     index               index.html;

  41.     try_files           $uri $uri/ /index.html;

  42.   }

  43.   

  44.   location ^~ /store/ {

  45.     alias               html/store/;

  46.     index               index.html index.htm;

  47.     try_files           $uri /store/index.html;

  48.   }

  49.   

  50.   # 接口代理

  51.   location  /api {

  52.     proxy_pass          http://localhost:8089;

  53.   }

  54. }


  55. # 子應(yīng)用二服務(wù)

  56. server {

  57.   listen                8002;

  58.   server_name           _;

  59.   location / {

  60.     root                html/school;

  61.     index               index.html;

  62.     try_files           $uri $uri/ /index.html;

  63.   }

  64.   

  65.   location ^~ /school/ {

  66.     alias               html/school/;

  67.     index               index.html index.htm;

  68.     try_files           $uri /school/index.html;

  69.   }

  70.   

  71.   # 接口代理

  72.   location  /api {

  73.     proxy_pass          http://localhost:10010;

  74.   }

  75. }

復(fù)制代碼


七、配置負載均衡

  1. upstream my_upstream {

  2.   server                http://localhost:9001;

  3.   server                http://localhost:9002;

  4.   server                http://localhost:9003;

  5. }


  6. server {

  7.   listen                9000;

  8.   server_name           test.com;


  9.   location / {

  10.     proxy_pass          my_upstream;

  11.     proxy_set_header    Host $proxy_host;

  12.     proxy_set_header    X-Real-IP $remote_addr;

  13.     proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;

  14.   }

  15. }

復(fù)制代碼


八、SSL 配置 HTTPS

  1. server {

  2.   listen                      80;

  3.   server_name                 <a  target="_blank">www.xxx.com</a>;

  4.   # 將 http 重定向轉(zhuǎn)移到 https

  5.   return 301 https://$server_name$request_uri;

  6. }


  7. server {

  8.   listen                      443 ssl;

  9.   server_name                 <a  target="_blank">www.xxx.com</a>;

  10.   ssl_certificate             /etc/nginx/ssl/www.xxx.com.pem;

  11.   ssl_certificate_key         /etc/nginx/ssl/www.xxx.com.key;

  12.   ssl_session_timeout         10m;

  13.   ssl_ciphers                 ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;

  14.   ssl_protocols               TLSv1 TLSv1.1 TLSv1.2;

  15.   ssl_prefer_server_ciphers   on;

  16.   

  17.   location / {

  18.     root                    /project/xxx;

  19.     index                   index.html index.htm index.md;

  20.     try_files               $uri $uri/ /index.html;

  21.   }

  22. }

復(fù)制代碼



TOP

QQ客服

免費電話

微信咨詢 在線咨詢 免費電話
獲取報價
您的稱呼:

*

您的電話:

*

您的郵箱:

*

提交 重置
重要的事情,電話里聊

接通客服

不方便的時候線上咨詢,在線等哦
主站蜘蛛池模板: 精品精品精品 | 国产成人精品视频免费大全 | 六月激情综合 | 亚洲人成一区二区三区 | 欧美日韩精品一区二区 | 亚洲欧美成人中文日韩电影 | 美女扒开胸罩露出奶了无遮挡免费 | 久久一区二区三区不卡 | 久久精品国产2020观看福利色 | 欧美日韩a级a | 国产乱理伦片在线观看大陆 | 免费成人福利视频 | 免费手机黄色网址 | 51精品国产 | 亚洲一区二区三区成人 | 国产欧美日韩综合在线一 | 婷婷激情综合 | 亚欧美图片自偷自拍另类 | 中国一级片免费看 | 日本三级2018亚洲视频 | 在线观看黄色毛片 | 成人黄页网站免费观看大全 | 涩涩网站在线看 | 无内丝袜透明在线播放 | 日韩欧一级毛片在线播无遮挡 | 亚洲 欧美 中文 日韩专区 | 深夜释放自己黄瓜视频 | 久久99视频免费 | 一级毛片在线看在线播放 | 天天更新天天久久久更新影院 | 一区二区在线视频免费观看 | 国产亚洲精品国产福利在线观看 | 国产成人午夜精品影院游乐网 | 色鬼影院 | 欧美日韩亚毛片免费观看 | 国产初高中生厕所小便 | 日韩啪啪片 | 久久久久久99精品 | 国产一级特黄在线播放 | 97视频在线观看免费 | 久久性生活片 |