成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Nginx靜態文件的配置與安全認定

開發 前端
Nginx靜態文件需要我們不斷的維護,但是要如何才能進行配置和維護呢?下面的命令會對你有所幫助,希望大家享受Nginx的服務。

本文主要講述Nginx靜態文件,怎樣創建Nginx靜態文件項目。這些內容都是一些門戶網站和技術論壇找到的,中間可能有不少錯誤是我沒有挑出的,歡迎大家 指正。

我們的目標是配置一個服務最快且cpu/io利用最有效的服務器,更重要的是一個安全的web服務器,下面的配置文件適用于***版Nginx

  1. #######################################################  
  2. ### Calomel.org /etc/Nginx.conf BEGIN  
  3. #######################################################  
  4. #  
  5. pid /var/run/Nginx.pid;  
  6. user Nginx Nginx;  
  7. worker_processes 2;  
  8. events {  
  9. worker_connections 1024;  
  10. }  
  11. http {  
  12. ## MIME types  
  13. include mime.types;  
  14. # types {  
  15. # image/gif gif;  
  16. # image/jpeg jpg;  
  17. # image/png png;  
  18. # image/bmp bmp;  
  19. # image/x-icon ico;  
  20. # text/css css;  
  21. # text/html html;  
  22. # text/plain bob;  
  23. # text/plain txt;  
  24. }  
  25. default_type application/octet-stream;  
  26. ## Size Limits  
  27. client_body_buffer_size 8k;  
  28. client_header_buffer_size 1k;  
  29. client_max_body_size 1k;  
  30. large_client_header_buffers 1 1k;  
  31. ## Timeouts   
  32. client_body_timeout 5;  
  33. client_header_timeout 5;  
  34. keepalive_timeout 5 5;  
  35. send_timeout 5;  
  36. ## General Options  
  37. ignore_invalid_headers on;  
  38. limit_zone gulag $binary_remote_addr 1m;  
  39. recursive_error_pages on;  
  40. sendfile on;  
  41. server_name_in_redirect off;  
  42. server_tokens off;  
  43. ## TCP options   
  44. tcp_nodelay on;  
  45. tcp_nopush on;  
  46. ## Compression  
  47. gzip on;  
  48. gzip_static on;  
  49. gzip_buffers 16 8k;  
  50. gzip_comp_level 9;  
  51. gzip_http_version 1.0;  
  52. gzip_min_length 0;  
  53. gzip_types text/plain text/html text/css image/x-icon image/
    bmp;  
  54. gzip_vary on;  
  55. ## Log Format  
  56. log_format main '$remote_addr $host $remote_user [$time_
    local] "$request" '  
  57. '$status $body_bytes_sent "$http_referer" "$http_user_
    agent" "$gzip_ratio"';  
  58. ## Deny access to any host other than (www.)mydomain.com  
  59. server {  
  60. server_name _; #default  
  61. return 444;  
  62. }  
  63. ## Server (www.)mydomain.com  
  64. server {  
  65. access_log /var/log/Nginx/access.log main buffer=32k;  
  66. error_log /var/log/Nginx/error.log info;  
  67. expires 31d;  
  68. limit_conn gulag 5;  
  69. listen 127.0.0.1:8080 rcvbuf=64k backlog=128;  
  70. root /disk01/htdocs;  
  71. server_name mydomain.com www.mydomain;  
  72. ## SSL Options (only enable if you use a SSL certificate)  
  73. # ssl on;  
  74. # ssl_certificate /ssl_keys/mydomain.com_ssl.crt;  
  75. # ssl_certificate_key /ssl_keys/mydomain_ssl.key;  
  76. # ssl_ciphers HIGH:!ADH:!MD5;  
  77. # ssl_prefer_server_ciphers on;  
  78. # ssl_protocols SSLv3;  
  79. # ssl_session_cache shared:SSL:1m;  
  80. # ssl_session_timeout 5m;  
  81. ## Only allow GET and HEAD request methods  
  82. if ($request_method !~ ^(GET|HEAD)$ ) {  
  83. return 444;  
  84. }  
  85. ## Deny illegal Host headers  
  86. if ($host !~* ^(mydomain.com|www.mydomain.com)$ ) {  
  87. return 444;  
  88. }  
  89. ## Deny certain User-Agents (case insensitive)  
  90. ## The ~* makes it case insensitive as opposed to just a ~  
  91. if ($http_user_agent ~* (Baiduspider|Jullo) ) {  
  92. return 444;  
  93. }  
  94. ## Deny certain Referers (case insensitive)  
  95. ## The ~* makes it case insensitive as opposed to just a ~  
  96. if ($http_referer ~* (babes|click|diamond|forsale|girl|jewelry|
    love|nudit|organic|poker|porn|poweroversoftware|sex|teen|
    video|webcam|zippo) ) {  
  97. return 444;  
  98. }  
  99. ## Redirect from www to non-www  
  100. if ($host = 'www.mydomain.com' ) {  
  101. rewrite ^/(.*)$ http://mydomain.com/$1 permanent;  
  102. }  
  103. ## Stop Image and Document Hijacking  
  104. location ~* (\.jpg|\.png|\.css)$ {  
  105. if ($http_referer !~ ^(http://mydomain.com) ) {  
  106. return 444;  
  107. }  
  108. }  
  109. ## Restricted Access directory  
  110. location ^~ /secure/ {  
  111. allow 127.0.0.1/32;  
  112. allow 10.10.10.0/24;  
  113. deny all;  
  114. auth_basic "RESTRICTED ACCESS";  
  115. auth_basic_user_file /var/www/htdocs/secure/access_list;  
  116. }  
  117. ## Only allow these file types to document root  
  118. location / {  
  119. if ($request_uri ~* (^\/|\.html|\.jpg|\.org|\.png|\.css|
    favicon\.ico|robots\.txt)$ ) {  
  120. break;  
  121. }  
  122. return 444;  
  123. }  
  124. ## Serve an empty 1x1 gif _OR_ an error 204 (No Content) 
    for favicon.ico  
  125. location = /favicon.ico {  
  126. #empty_gif;  
  127. return 204;  
  128. }  
  129. ## System Maintenance (Service Unavailable)   
  130. if (-f $document_root/system_maintenance.html ) {  
  131. error_page 503 /system_maintenance.html;  
  132. return 503;  
  133. }  
  134. ## All other errors get the generic error page  
  135. error_page 400 401 402 403 404 405 406 407 408 409 410 411 
    412 413 414 415 416 417  
  136. 500 501 502 503 504 505 /error_page.html;  
  137. location /error_page.html {  
  138. internal;  
  139. }  
  140. }  
  141. }  
  142. #  
  143. #######################################################  
  144. ### Calomel.org /etc/Nginx.conf END  
  145. #######################################################  

以上就是對Nginx靜態文件命令的詳細介紹希望大家有所收獲。

【編輯推薦】

  1. Nginx重啟的簡單命令 kill
  2. Nginx狀態監控如何實現自己的作用
  3. Nginx負載均衡配置的菜鳥修煉秘籍
  4. 深入學習有關Nginx負載均衡的安裝過程
  5. Nginx+PHP配置相關進程的簡要介紹
責任編輯:張浩 來源: 博客園
相關推薦

2024-01-24 13:40:45

2010-03-25 18:09:23

Nginx配置文件

2014-03-28 14:20:04

2011-11-08 13:46:44

靜態文件Nginx優化

2016-08-29 21:36:55

nginxWeb緩存

2018-01-26 10:49:19

2013-05-15 10:56:19

靜態路由器路由器設備配置

2013-07-15 10:39:43

2011-08-22 14:43:36

靜態路由器

2010-03-29 09:23:00

2010-03-30 18:04:45

Nginx http服

2010-03-30 15:25:42

Linux Nginx

2022-04-08 08:40:36

Nginx日志服務器

2013-06-05 13:31:25

2010-03-25 17:29:00

Nginx配置

2010-02-22 15:59:48

2020-04-09 13:23:29

Nginx配置文件模板

2022-07-07 10:43:58

安全配置管理SCM

2009-12-17 16:42:35

配置靜態路由

2010-03-25 18:31:03

Nginx配置文件
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 亚洲一区二区欧美 | 欧美1—12sexvideos | 欧美一级免费 | 高清国产一区二区 | 国产精品天堂 | 亚洲第一免费播放区 | 成人欧美一区二区三区在线播放 | 精国产品一区二区三区四季综 | 亚洲瑟瑟| 三级视频网站 | 久久久久亚洲视频 | 亚洲人成网亚洲欧洲无码 | 国产人免费人成免费视频 | 久久精品视频网站 | 欧美日韩在线一区二区三区 | 久久久久www| 亚洲福利在线视频 | 欧美色综合一区二区三区 | 亚洲精品一区二区在线观看 | 亚洲精彩视频在线观看 | 性高朝久久久久久久3小时 av一区二区三区四区 | 国产日韩一区二区三免费高清 | 韩日一区二区三区 | 日韩亚洲一区二区 | 国产一级片免费视频 | 成人综合在线视频 | 久久久久成人精品亚洲国产 | 亚洲九九精品 | 亚洲一区二区视频 | 91久久精品一区二区二区 | 欧美精品在线播放 | 精品国产乱码久久久久久中文 | 午夜视频免费在线观看 | 中文字幕在线看 | 天天草草草 | 在线欧美一区 | 中文字幕日韩一区 | 亚洲一二三区精品 | 国产日韩精品在线 | 国产精品一区二区三区四区五区 | 天天干天天草 |