සටහන: මෙම ලිපියේ ඇති සබැඳිවල Amazon වෙත අනුබද්ධ සබැඳි ඇතුළත් වේ. මෙම සබැඳි ක්ලික් කිරීම සඳහා ඔබෙන් අමතර කිසිවක් අය නොකෙරේ, නමුත් ඔබ මෙම සබැඳිවලින් එකක් හරහා යමක් මිලදී ගැනීමට තෝරා ගන්නේ නම් ඔබ මට සහාය වනු ඇත. ස්තූතියි!
ඔබගේ ලොග් /.DS_Store
, /backup.sql
, /.vscode/sftp.json
සහ තවත් බොහෝ URL වල පහර 404 කින් පිරී ඇත. මෙම ඉල්ලීම් බොහෝ දුරට හානිකර නොවන අතර, ඇත්ත වශයෙන්ම, ඔබේ සේවාදායකයට එම ස්ථානවල පිරිනැමීමට යමක් නොමැති නම්, ඔබ බොට්වරුන් සතුටු කළ යුතුය.
ඇයි?
සේවාදායකයකට පහර දීම සම්පත් අධික කාර්යයක් වන අතර, එම බොට් වල විවිධ URL වල පුළුල් ලැයිස්තුවක් ඇති බැවින්, ඔබට උදව් කළ හැකි හැඹිලි යාන්ත්රණයක් නොමැත. ඊට අමතරව, බොට් නැවැත්වීම සැමවිටම ආරක්ෂිත පියවරකි.
Wordpress පිවිසුම් පිටුවට එල්ල වන ප්රහාර අවම කිරීම සඳහා අපි මීට පෙර HAProxy භාවිතා කර ඇත්තෙමු, දෝෂ 404 ක් ආවරණය කිරීම සඳහා එම ප්රවේශය දීර්ඝ කිරීම අදහසයි.
බොට්ස් ඔබේ සේවාදායකය තුළ විනාශයක් ඇති කිරීමට උපරිම උත්සාහයක් ගනු ඇත.
මම Sasa Tekovic ගෙන් ආභාෂය ලබා ගත්තා, එනම් සැබෑ සෙවුම් යන්ත්ර බඩගා යන්නන් අවහිර නොකිරීම සහ නීත්යානුකූල පරිශීලකයින් අවහිර නොකිරීමෙන් සැබෑ අතුරුදහන් වූ සම්පත් - ඔබේ පැත්තෙන් දෝෂයක් - වැළැක්වීම සඳහා ස්ථිතික සම්පත් මත 404 ඉඩ දීම පිළිබඳව.
ක්රියාත්මක කිරීමට පෙර, දේශීය පරීක්ෂණ පරිසරයක් සකස් කිරීම සැමවිටම හොඳයි. අපි HAProxy
සහ Apache
Docker
භාවිතයෙන් ආරම්භ කරමු. අපට එම 404
ලබා දීමට සැබෑ පසුපෙළ සේවාදායකයක් අවශ්ය වේ.
version : '3' services: haproxy: image: haproxy:3.1.3-alpine ports: - "8100:80" volumes: - "./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg" networks: - webnet apache: image: httpd:latest container_name: apache1 ports: - "8080:80" volumes: - ./html:/usr/local/apache2/htdocs/ networks: - webnet networks: webnet:
ඉන්පසු, docker-compose up
ධාවනය කරන්න, එවිට ඔබට ඔබගේ බ්රවුසරයේ localhost:8100
වෙත ප්රවේශ විය හැක.
haproxy.cfg
ගොනුව බොහෝ දුරට පැහැදිලි ය:
global log stdout format raw daemon debug defaults log global mode http frontend main bind *:80 acl static_file path_end .css .js .jpg .jpeg .gif .ico .png .bmp .webp .csv .ttf .woff .svg .svgz acl excluded_user_agent hdr_reg(user-agent) -i (yahoo|yandex|kagi|(google|bing)bot) # tracks IPs but exclude hits on static files and search engine crawlers http-request track-sc0 src table mock_404_tracking if !static_file !excluded_user_agent # increment gpc0 if response code was 404 http-response sc-inc-gpc0(0) if { status 404 } # checks if the 404 error rate limit was exceeded http-request deny deny_status 403 content-type text/html lf-string "404 abuse" if { sc0_gpc0_rate(mock_404_tracking) ge 5 } # whatever backend you're using use_backend apache_servers backend apache_servers server apache1 apache1:80 maxconn 32 # mock backend to hold a stick table backend mock_404_tracking stick-table type ip size 100k expire 10m store gpc0,gpc0_rate(1m)
එක විනාඩියක් ඇතුළත ඉල්ලීම් 404 කට හිට්ස් 5 කට වඩා ලැබුනොත්, බොට් එක විනාඩි 10 කට තහනම් කරනවා.
පවතින පරිදි, මෙම සැකසුම අධික 404s ජනනය කරන බොට් සඳහා ඵලදායී ලෙස අනුපාත සීමා කරයි. කෙසේ වෙතත්, අපි එය අපගේ පෙර උදාහරණය සමඟ ඒකාබද්ධ කිරීමටද කැමැත්තෙමු, එහිදී අපි WordPress
හි ප්රහාර අවහිර කිරීමට HAProxy
භාවිතා කළෙමු.
global log stdout format raw daemon debug defaults log global mode http frontend main bind *:80 # We may, or may not, be running this with Cloudflare acting as a CDN. # If Cloudflare is in front of our servers, user/bot IP will be in # 'CF-Connecting-IP', otherwise user IP with be in 'src'. So we make # sure to set a variable 'txn.actual_ip' that has the IP, no matter what http-request set-var(txn.actual_ip) hdr_ip(CF-Connecting-IP) if { hdr(CF-Connecting-IP) -m found } http-request set-var(txn.actual_ip) src if !{ hdr(CF-Connecting-IP) -m found } # gets the actual IP on logs log-format "%ci\ %hr\ %ft\ %b/%s\ %Tw/%Tc/%Tt\ %B\ %ts\ %r\ %ST\ %Tr IP:%{+Q}[var(txn.actual_ip)]" # common static files where we may get 404 errors and also common search engine # crawlers that we don't want blocked acl static_file path_end .css .js .jpg .jpeg .gif .ico .png .bmp .webp .csv .ttf .woff .svg .svgz acl excluded_user_agent hdr_reg(user-agent) -i (yahoo|yandex|kagi|google|bing) # paths where we will rate limit users to prevent Wordpress abuse acl is_wp_login path_end -i /wp-login.php /xmlrpc.php /xmrlpc.php acl is_post method POST # 404 abuse blocker # track IPs but exclude hits on static files and search engine crawlers # increment gpc0 counter if response status was 404 and deny if rate exceeded http-request track-sc0 var(txn.actual_ip) table mock_404_track if !static_file !excluded_user_agent http-response sc-inc-gpc0(0) if { status 404 } http-request deny deny_status 403 content-type text/html lf-string "404 abuse" if { sc0_gpc0_rate(mock_404_track) ge 5 } # wordpress abuse blocker # track IPs if the request hits one of the monitored paths with a POST request # increment gpc1 counter if path was hit and deny if rate exceeded http-request track-sc1 var(txn.actual_ip) table mock_wplogin_track if is_wp_login is_post http-request sc-inc-gpc1(1) if is_wp_login is_post http-request deny deny_status 403 content-type text/html lf-string "login abuse" if { sc1_gpc1_rate(mock_wplogin_track) ge 5 } # your backend, here using apache for demonstration purposes use_backend apache_servers backend apache_servers server apache1 apache1:80 maxconn 32 # mock backends for storing sticky tables backend mock_404_track stick-table type ip size 100k expire 10m store gpc0,gpc0_rate(1m) backend mock_wplogin_track stick-table type ip size 100k expire 10m store gpc1,gpc1_rate(1m)
stick tables
දෙකක් සමඟ දුවමින්, තර්ජන දෙකම නැවැත්වීම.
ඔන්න ඔයාට ඒක තියෙනවා. HAProxy නැවතත් සරල ප්රතිලෝම ප්රොක්සියක් ලෙසට වඩා බොහෝ දේ සඳහා භාවිතා කරනවා. ඒක පොඩි Swiss Knife එකක්!
අලුත්වැඩියා කටයුතු වලදී මෙම ප්රධාන ලාම්පුව ක්රීඩාව වෙනස් කරන්නෙකු වී ඇත.
මට එකක් තිබුණා, නමුත් එය කැඩුන විට, එය ප්රතිස්ථාපනය කිරීමට පසුබට වී, දුරකථනයේ ෆ්ලෑෂ් ලයිට් එක වෙත යොමු වුණා. ඇත්ත වශයෙන්ම, එය ක්රියාත්මක වේ - නමුත් ඔබ නැවත අත් දෙකම නිදහස්ව තබා ගැනීමේ පහසුව අත්විඳින විට - ආපසු යාමක් නැත. ඔබට විශ්වාසදායක, අත්-නිදහස් ආලෝකකරණයක් අවශ්ය නම්, මෙය අත්යවශ්ය දෙයකි!
මෙම සටහන මුලින් පළ කරන ලද්දේ https://wasteofserver.com/stop-404-prying-bots-with-haproxy/ හි වන අතර, ඔබට එහි නව සංශෝධන සහ අමතර අදහස් සොයාගත හැකිය.