国产91丝袜在线熟_男人久久天堂_国产一伦一伦一伦_五月天婷婷久久_在线免费亚洲视频_免费同性女女aaa免费网站

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

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

與我們合作

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

有一個品牌項目想和我們談談嗎?

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

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

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

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

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

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

傳 真: 021-61488448

郵 箱: admin@wumujituan.com

快速提交您的需求 ↓

Nginx常用配置

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

一、基礎(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. }

復制代碼


二、隱藏 Nginx 版本信息

  1. http {

  2.   server_tokens         off;

  3. }

復制代碼



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

  1. server {

  2.   listen                80 default;

  3.   server_name           _;

  4.   return                500;

  5. }

復制代碼


四、啟動 web 服務 (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. }

復制代碼


五、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. }

復制代碼


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

  1. server {

  2.   listen                80;

  3.   server_name           _;

  4.   

  5.   # 主應用

  6.   location / {

  7.     root                html/main;

  8.     index               index.html;

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

  10.   }

  11.   

  12.   # 子應用一

  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.   # 子應用二

  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. # 子應用一服務

  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. # 子應用二服務

  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. }

復制代碼


七、配置負載均衡

  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. }

復制代碼


八、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. }

復制代碼



TOP

QQ客服

免費電話

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

*

您的電話:

*

您的郵箱:

*

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

接通客服

不方便的時候線上咨詢,在線等哦
主站蜘蛛池模板: 日本做暖暖视频高清观看 | 91国产精品| 亚洲精品乱码久久久久久金桔影视 | 国产精品亲子伦av一区二区三区 | 成人在线一区二区 | 偷拍一区二区三区四区 | 国产精品免费精品自在线观看 | 综合久久亚洲 | 黄网免费看 | 成人中文网 | 欧美视频在线播放 | 99精品一区二区三区 | 中文字幕在线精品 | 亚洲欧美成人a毛片 | 亚洲免费人成在线视频观看 | 国产精品美女久久久久av麻豆 | 亚洲乱码国产乱码精品精98午夜 | 日韩视频精品 | 日本在线视频免费观看 | 国产乱视频| 国产精品国产成人国产三级 | 亚洲一区二区三区在线免费观看 | 亚洲午夜精品 | 成人午夜| 成人羞羞网站 | 一级黄色a毛片 | 欧美在线小视频 | 精品在线一区二区 | 日韩av中文 | 91中文字幕在线 | 欧美视频精品在线观看 | 日韩一区电影 | 国产在线一区二区 | 亚洲va国产va天堂va久久 | 中文字幕在线观看免费 | 国产成人精品一区二区三区四区 | 国产美女在线观看 | 中文字幕在线一区二区三区 | 免费一区二区三区 | 黄色片免费在线观看视频 | 成人在线|