nginx 配置认证

  1. -c:创建一个加密文件;
  2. -n:不更新加密文件,只将加密后的用户名密码显示在屏幕上;
  3. -m:默认采用MD5算法对密码进行加密;
  4. -d:采用CRYPT算法对密码进行加密;
  5. -p:不对密码进行进行加密,即明文密码;
  6. -s:采用SHA算法对密码进行加密;
  7. -b:在命令行中一并输入用户名和密码而不是根据提示输入密码;
  8. -D:删除指定的用户
  9. ### 添加用户
  10. htpasswd -bc whitelist ops_user 1q2w3e
  11. ### 新增用户
  12. htpasswd -b whitelist test 123456
  13. ### 删除用户
  14. htpasswd -D whitelist test
  15. ### 修改用户密码
  16. htpasswd -b whitelist ops_user 123qwe


  1. satisfy any;
  2. include /etc/nginx/whitelist;
  3. deny all; auth_basic "Closed Site!";
  4. # auth_basic_user_file /etc/nginx/htpasswd;
  5. error_page 403 /40x-sprout.html;
  6. location = /40x-sprout.html {
  7. allow all;
  8. }
  9. error_page 500 502 503 504 /50x.html;
  10. location = /50x.html {
  11. root /usr/share/nginx/html;
  12. }

whitelist

  1. ##2020-09-10
  2. allow 123.108.109.140;
  3. ## 2020-09-09
  4. allow 103.240.203.138;
  5. ## 2020-08-26
  6. allow 123.108.109.142;
  7. ## 2020-07-29
  8. allow 202.60.255.139;
  9. # 2020-07-22
  10. allow 58.33.96.219;
  11. ## 2020-01-16

401.html

  1. cat 401.html
  2. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
  3. <html>
  4. <head><title>403 Forbidden</title></head>
  5. <body bgcolor="white">
  6. <h1>403 Forbidden</h1>
  7. <p>You don't have permission to access the URL on this server. Sorry for the inconvenience.<br/>
  8. Non-office network or VPN export IP, please Enterprise WeChat Contact <a target = "_blank" href="wxwork:https://work.weixin.qq.com/u/1vc61041e4dcf7f5350" title="Click View Site " > light&ezbuy </a> ,Ops <a target = "_blank" href="https://www.tapd.cn/20257541/prong/stories/1stories_list" title="Click View Site " > light-Ops.</a>
  9. <!--Non-office network or VPN export IP, please Enterprise WeChat Contact <a target = "_blank" href="wxwork://message?uin=1688850522843493&source=21" title="Click View Site " > zhiyiz&wangl</a> ,Ops <a target = "_blank" href="https://www.tapd.cn/20257541/prong/stories/1stories_list" title="Click View Site " > light-Ops.</a> -->
  10. <br/>
  11. <br/><a href="mailto:skydong@light.com"> R&D application engineer Email</a>
  12. <br/><a href="mailto:ops_notice@light.com"><font size="3"> Site Reliability Engineering Email</a>
  13. <!--<br/><a href="mailto:ops_notice@light.com"><font size="3"> Operation engineer Email</a>
  14. This is a our test website, please visit our official website <a href="http://skydong.com/contact/index.html" title="Click View Site " ><font size="5"> www.skydong.com</a>! -->
  15. </font><br/>
  16. Thank you very much!</p>
  17. URL: http://cachef-co1.ezbuy.me
  18. <br/>Date:
  19. <script language="JavaScript" type="text/javascript">
  20. var enabled = 0; today = new Date();
  21. var date;
  22. M=today.getMonth() + 1
  23. D=today.getDate()
  24. HH=today.getHours()
  25. MM=today.getMinutes()
  26. SS=today.getSeconds()
  27. if (M<10)
  28. {
  29. M="0"+M
  30. }
  31. if (D<10)
  32. {
  33. D="0"+D
  34. }
  35. if (MM<10)
  36. {
  37. MM="0"+MM
  38. }
  39. if (HH<10)
  40. {
  41. HH="0"+HH
  42. }
  43. if (SS<10)
  44. {
  45. SS="0"+SS
  46. }
  47. date = (today.getFullYear()) + "/" + M + "/" + D + " " + HH+":"+MM+":"+SS +"";
  48. document.write(date);
  49. </script>
  50. <hr/>Powered by light-ops!</body>
  51. </html>

40x-xxx.html

  1. cat /usr/local/openresty/nginx/html/40x-sprout.html
  2. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
  3. <html>
  4. <head><title>403 Forbidden</title></head>
  5. <body bgcolor="white">
  6. <h1>403 Forbidden</h1>
  7. <p>You don't have permission to access the URL on this server. Sorry for the inconvenience.<br/>
  8. Non-office network and VPN export IP, please Enterprise WeChat Contact <a target = "_blank" href="wxwork:https://work.weixin.qq.com/u/vc61041e4dcf7f5350" title="Click View Site " > zhiyiz&wanglei</a> ,Ops <a target = "_blank" href="https://www.tapd.cn/20257541/prong/stories/stories_list" title="Click View Site " > light-Ops.</a>
  9. <!--Non-office network and VPN export IP, please Enterprise WeChat Contact <a target = "_blank" href="wxwork://message?uin=1688850522843493&source=2" title="Click View Site " > zhiyizhao&wanglei</a> ,Ops <a target = "_blank" href="https://www.tapd.cn/20257541/prong/stories/stories_list" title="Click View Site " > light-Ops.</a> -->
  10. <br/>
  11. <br/><a href="mailto:zhiyiz@lightinthebox.com"> R&D application engineer Email</a>
  12. <br/><a href="mailto:ops_noti@lightinthebox.com"><font size="3"> Site Reliability Engineering Email</a>
  13. <!--<br/><a href="mailto:ops_noti@lightinthebox.com"><font size="3"> Operation engineer Email</a>
  14. This is a our test website, please visit our official website <a href="http://skydong.com/contact/index.html" title="Click View Site " ><font size="5"> www.skydong.com</a>! -->
  15. </font><br/>
  16. Thank you very much!</p>
  17. URL: http://sprout.65eamll1.net
  18. <br/>Date:
  19. <script language="JavaScript" type="text/javascript">
  20. var enabled = 0; today = new Date();
  21. var date;
  22. M=today.getMonth() + 1
  23. D=today.getDate()
  24. HH=today.getHours()
  25. MM=today.getMinutes()
  26. SS=today.getSeconds()
  27. if (M<10)
  28. {
  29. M="0"+M
  30. }
  31. if (D<10)
  32. {
  33. D="0"+D
  34. }
  35. if (MM<10)
  36. {
  37. MM="0"+MM
  38. }
  39. if (HH<10)
  40. {
  41. HH="0"+HH
  42. }
  43. if (SS<10)
  44. {
  45. SS="0"+SS
  46. }
  47. date = (today.getFullYear()) + "/" + M + "/" + D + " " + HH+":"+MM+":"+SS +"";
  48. document.write(date);
  49. </script>
  50. <hr/>Powered by sprout.elitb.com!</body>
  51. </html>