Te matauranga Nga tohutohu ngawari ki te mahi me te ratonga Profitserver
Main Te matauranga Te whakaheke i te uta o te tūmau

Te whakaheke i te uta o te tūmau


I roto i tenei tuhinga, ka rukuhia e tatou he aha te pikinga o te utaina o te tūmau me te matapaki i nga momo huarahi ki te arotau i nga tikanga kawenga nui. Ka aro nui ki te arotautanga waehere i roto i te Apache/Nginx me MySQL, ka korero tatou mo te keteroki hei taputapu awhina, me te whakaaro ano hoki mo nga riri o waho, penei i nga whakaeke DDOS, me nga huarahi hei aukati i a raatau.

He aha te utaina o te Tūmau

I mua i te haere ki te arotautanga tūmau, he mea tika ki te whakahaere i te tino tātaritanga o te kawenga o naianei mo nga rauemi. Kei roto i tenei ko te ine i te uta CPU, te whakamahi RAM, te mahi whatunga, me etahi atu tawhā matua. Ma te mohio ki nga hihiko me nga taumahatanga teitei ka taea te tautuhi i nga kohungahunga me te arotau i te tohatoha rauemi, na reira ka piki ake te pumau me te mahi o te hanganga o te tūmau.

Mo te rapurongoā tuatahi mo te utaina nui o te tūmau, ka tūtohu mātou kia whakahaere a tātaritanga tūmau whānui. Mena kaore i te rawaka, he taipitopito ake tātari rauemi he mea tika. Hei taputapu awhina, te torotoro i te rangitaki o te Linux Ka taea e te tūmau te awhina, na te mea kei konei te putake o te raru i te nuinga o nga keehi.

Te whakapai ake i te Apache/Nginx Server

Kua Nui ake te Utatu Tūmau Na te Taupūtanga

Ko te nui ake o te uta na te tohu tohu i runga i te tūmau ka puta, hei tauira, ina karapahia e nga miihini rapu te maha o nga wharangi kei runga i to papaanga. Ka taea e tenei te kaha ake te whakamahi i nga rauemi a te tūmau, a, na reira, ka whakahekehia te mahinga o te pae. He ngawari noa te tautuhi i te take; Me whakatuwhera koe i te konae kei:

/var/www/httpd-logs/sitename.access.log

Ina tohuhia e nga miihini rapu, ka kite te kaiwhakamahi i nga whakaurunga e whai ake nei:

11.22.33.44 - - [Date and Time] "GET /your-page-path HTTP/1.1" 200 1234 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

Hei otinga tuatahi ki te whakaiti i te kawenga, ka taea e koe te whakamahi i te tautuhinga o nga tohu meta "noindex" a "kahore" i runga i nga wharangi kaore e tika kia taurangi. Ko te otinga tuarua ko te .htaccess konae, kei reira nga whakaurunga e pa ana ki nga miihini rapu motuhake me taapiri, hei tauira, ki te huna mai i a Yandex me Google:

SetEnvIfNoCase User-Agent "^Yandex" search_bot
SetEnvIfNoCase User-Agent "^Googlebot" search_bot
Order Allow,Deny
Allow from all
Deny from env=search_bot

Waihoki, me whakatika mo etahi atu miihini rapu. Me tohu ko nga kaha o te .htaccess ehara i te mea noa ki te aukati i te tohu tohu. Ka tūtohu kia waia ake ki ona ahuatanga matua i roto i te tuhinga.

Te whakamahi i nga Tautuhinga Keteroki

Ko nga tautuhinga keteroki hē i runga i te tūmau ka nui te kawenga. Ki te arotau i tenei tawhā, Me hanga huringa e hāngai ana ki te kōnae whirihoranga ranei .htaccess. Mo te Apache, he pai ake te whiringa whakamutunga, mo Nginx - te mea o mua.

I runga i te Apache tūmau, me whakatuwhera koe i te .htacess konae me te whakauru i te waehere e whai ake nei:

<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf|doc|docx)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

Na, whakahohea te pau kōwae mā te whakahau:

sudo a2enmod expires

Muri iho, whakaara ano i te tūmau tukutuku:

sudo service apache2 restart

A ka whakahohe i te kōwae mā te whakapūtā:

ExpiresActive On

I runga i te Nginx tūmau, he rawaka ki te tāpiri i te waehere e whai ake nei ki te kōnae whirihoranga:

location ~* .(jpg|jpeg|gif|png|ico|css|swf|flv|doc|docx)$ {
root /var/www/yoursite.com;
}

A ka mahi i te utaina ratonga:

sudo service nginx restart

Kia mahara me enei tautuhinga, te tukua a Whakaae ka takahia nga tohutohu.

Te whakamahi i te Kopeke Raraunga

Whakahohe te kōpeketanga raraunga mā te whakamahi Kawhaka i runga i nga ratonga tukutuku a Apache me Nginx ka awhina i te whakaiti i te nui o nga raraunga ka tukuna i waenga i te tūmau me te kiritaki, e pai ake ai te mahi me te whakaiti i te wa o te utaina o te whārangi tukutuku.

Hei whakahohe Kawhaka on Apache, me whakahohe koe i te mod_deflate kōwae:

sudo a2enmod deflate

Na, whakaara ano i te tūmau tukutuku:

sudo service apache2 restart

Ka mutu, taapirihia te poraka e whai ake nei ki te konae whirihoranga, .htaccess ranei:

<IfModule mod_deflate.c>
# Configure compression for specified file types
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript application/json

# If the browser matches the specified pattern, apply compression only to text/html files
BrowserMatch ^Mozilla/4 gzip-only-text/html

# If the browser matches the specified version patterns of Mozilla 4.0.6, 4.0.7, 4.0.8, disable compression
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# If the browser is MSIE (Internet Explorer), disable compression for all files except text/html
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# If the request contains the specified pattern (extensions of image files), disable compression
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
</IfModule>

Ma tenei whirihoranga ka taea te kōpeketanga mo etahi momo konae me te mono mo nga whakaahua.

I roto i te take o Nginx, whirihoranga puta i roto i te http poraka o te kōnae whirihoranga. Ko te waehere e whai ake nei me taapiri:

gzip on;
gzip_disable "msie6";

# Adds the Vary header, indicating that the response may change depending on the Accept-Encoding header value
gzip_vary on;

# Enables compression for any proxy servers
gzip_proxied any;

# Sets the compression level. A value of 6 provides a good balance between compression efficiency and resource use
gzip_comp_level 6;

# Sets the size of the buffer for compressed data (16 buffers of 8 kilobytes each)
gzip_buffers 16 8k;

# Specifies that data compression should be used only for HTTP version 1.1 and higher
gzip_http_version 1.1;

# Sets the file types that can be compressed
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

He rite ki Apache, i konei ka tautuhia nga tawhā kōpeketanga mo etahi momo konae. Whai muri i te whakarereketanga ki tetahi o nga tūmau tukutuku, me utaina ano te ratonga:

sudo service apache2 restart

Or

sudo service nginx restart

DDOS Attack i runga i te Tūmau

Ko te kawenga o te tūmau teitei ka puta mai i te whakaekenga a DDoS. Ko te tautuhi i te aroaro o te whakaeke DDoS ka taea te mahi ma te aro turuki i te piki ohorere o nga waka, nga tono rerekee, me te heke o nga mahi a nga kaitoro. Ko te arotake i nga raarangi mo nga tono tukurua mai i tetahi wahitau IP, matawai tauranga ranei ka tohu pea he whakaeke DDoS. He maha nga tikanga whakamarumaru, engari ka korero noa tatou i nga kaupapa.

Ma te whakamahi i te CDN (Whatunga Tuku Ihirangi). Ka taea e te CDN te mahi hei takawaenga i waenga i to tūmau tukutuku me nga kaiwhakamahi, ka tohatoha i nga hokohoko me te keteroki ihirangi hei whakaiti i te paanga o te whakaeke DDoS. Ka taea hoki e nga CDN te whakauru i nga tikanga tiaki DDoS, tae atu ki te tohatoha uta me te tātari waka.

Te whirihora i nga papaahi me nga punaha rapunga pokanoa (IDS/IPS). Ka taea te whirihora i nga papaahi ki te tarai i nga waka i runga i nga momo paearu, penei i nga wahitau IP me nga tauranga. Ka taea e te IDS/IPS te kite i nga whanonga waka rerekee me te aukati i nga hononga hihira. Ka taea e enei taputapu te whai hua ki te aroturuki me te aukati i nga hokohoko kino.

Te whirihora i nga tūmau tukutuku Apache me Nginx hei whakaiti i te paanga o nga whakaeke DDoS.

Hei otinga mo Apache, ka taea e matou te mod_evasive kōwae. Hei mahi i tenei, whakakorehia, taapirihia ranei te rarangi e whai ake nei i roto i te httpd.conf or apache2.conf kōnae whirihoranga:

LoadModule evasive20_module modules/mod_evasive.so

I roto i te konae ano, me taapiri he paraka tautuhinga:

<IfModule mod_evasive20.c>
# Hash table size for storing request information
DOSHashTableSize 3097

# Number of requests to one page before activating protection
DOSPageCount 2
DOSPageInterval 1

# Number of requests to all pages before activating protection
DOSSiteCount 50
DOSSiteInterval 1

# Blocking period in seconds for IP addresses
DOSBlockingPeriod 10
</IfModule>

Waihoki, ka whakahohehia e matou te mod_ratelimit kōwae:

LoadModule ratelimit_module modules/mod_ratelimit.so

Me te taapiri i te whirihoranga:

<IfModule mod_ratelimit.c>
# Setting the output filter for rate limiting (Rate Limit)
SetOutputFilter RATE_LIMIT

# Beginning of the settings block for the location "/login"
<Location "/login">

# Setting the environment variable rate-limit with a value of 1
SetEnv rate-limit 1

# Ending of the settings block for the location "/login"
</Location>
</IfModule>

Ko te whirihoranga mo Nginx he rite ki te Apache. I roto i te nginx.conf whirihora, me whakamahi nga tohutohu e whai ake nei:

http {
...
# Defining a zone for connection limits
limit_conn_zone $binary_remote_addr zone=addr:10m;

# Defining a zone for request limits
limit_req_zone $binary_remote_addr zone=req_zone:10m rate=1r/s;

server {
        ...
        # Configuring connection limits
        limit_conn addr 10;

        # Configuring request limits
        limit_req zone=req_zone burst=5;

        ...
    }
}

Whai muri i te whakarereketanga o ia ratonga, me uta ano:

sudo systemctl restart apache2

Ranei:

sudo systemctl restart nginx

Ko enei tauira he whirihoranga taketake anake, ka taea te whakarereke i runga i nga whakaritenga motuhake me te ahua o nga whakaeke.

Te arotau i nga Uiui MySQL

Ka taea te whakatutuki i nga paatai ​​​​papaunga raraunga MySQL i runga i te tūmau tukutuku i roto i nga huarahi rereke, a ko tetahi o enei ko te whirihoranga tika o te konae whirihoranga. Ko te tikanga, ka whakaingoatia tenei konae taku.cnf or taku.ini a kei roto i te / etc / or /etc/mysql/ whaiaronga. Me whakatuwhera koe ka mahia nga huringa e whai ake nei:

[mysqld]
# Location of the file for recording slow queries. Be sure to replace it with your path
log-slow-queries = /var/log/mariadb/slow_queries.log

# Threshold time for considering slow queries (in seconds)
long_query_time = 5

# Enabling recording of queries that do not use indexes
log-queries-not-using-indexes = 1

# Disabling query caching
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 1M

# Size of temporary tables
tmp_table_size = 16M
max_heap_table_size = 16M

# Size of the thread cache
thread_cache_size = 16

# Disabling name resolving
skip-name-resolve = 1

# Size of the InnoDB buffer pool. Set to 50-70% of available RAM
innodb_buffer_pool_size = 800M

# Size of the InnoDB log file
innodb_log_file_size = 200M

Me whai whakaaro ano tatou ki etahi atu taunakitanga ka taea te whakahaere i te taunekeneke me te papaunga raraunga tūmau:

  1. Whakamahia te HE WHAKAMAHI whakahau i mua i te uiui SQL hei tātari i tana mahi. Ma tenei ka taea e koe te tiki mahere mahi mo te patai me te whakatau ko wai nga tohu ka whakamahia, ko nga ripanga ka karapahia, aha atu.
  2. Ka tere ake nga taupū i te rapu raraunga, no reira ka taea e nga taupū i hangaia tika te whakapai ake i te mahi uiui. Kia tupato ki nga pou e whakamahia ana i roto HEA or Hono tikanga.
  3. A ape i te whakamahi WHAKANUI *. Tauwhāitihia ngā tīwae e tika ana mō tō uiui, kaua ki te kōwhiri i ngā tīwae katoa i tētahi ripanga.
  4. A ape i te whakamahi i nga mahi i roto HEA tikanga. Te whakamahi i nga mahi (penei E LI WAWA, UPOKO, TO'OHEMÁ, RIGHT) i roto i HEA Ka taea e nga tikanga te hanga i nga tohu hei koretake. Ngana ki te karo i to raatau whakamahi tika i nga ahuatanga.
  5. whakamahi INNER JOIN ka taea, i te mea he pai ake te mahi. Me whakarite kia whai taupū nga pou e hono ana mo te hono.
  6. whakamahi Tuhinga ki te aukati i te maha o nga rarangi kua hoki mai mena ka hiahia koe ki te tiki i etahi o nga hua.
  7. Whakaarohia te keteroki i nga hua patai, ina koa he uaua te huri, hei whakaiti i te uta o te tūmau.

Ka Waihanga Te Tūmau Mēra i te Uta Nui i runga i te Tūmau

I roto i tenei waahanga, ka tirotirohia me pehea te whakatau he nui te kawenga o te tūmau mēra me nga huarahi ka taea ki te arotau i tana mahi, tae atu ki te tirotiro i te rarangi karere me te whirihora i nga tawhā tūmau. Me timata ma te taki i te rarangi karere. Ko te mailq Ka taea e te whaipainga te awhina i tenei, ki te whakahohe, whakauruhia te whakahau e rite ana ki te tauranga:

mailq

Ka whakaatu tenei i te rarangi o nga karere kei roto i te rarangi, mena he. Ka whakaatuhia ia karere me tana tohu motuhake me nga korero mo te mana tuku. Ka taea te whiwhi hua rite ma te arotake i nga raarangi a nga kaihoko mēra.

I roto i te nuinga o nga keehi, ka nui te utaina mena ka taupatupatu te kaimau i te wa ka tiimata te tuku mokowhiti. Heoi, ki te i muri i te tirotiro i te kaiwhakahaere e maia ana kaore i whakaekehia te tūmau mai i waho me te kore e warewarehia e nga kaiwhakamahi te mokowhiti, kua tae ki te wa ki te neke ki te arotau i te tūmau mēra. Anei nga taahiraa hei awhina:

  1. Me whakarite kia tika te whirihora o nga rekoata DNS o to rohe, tae atu ki SPF, DKIM, a DMARC nga rekoata hei whakapai ake i te tuku mēra me te whakamarumaru ki te mokowhiti. Ko te whirihoranga tika o nga tawhā ka kitea i roto i te tuhinga i runga tātaritanga tūmau mēra.
  2. Tirohia nga tautuhinga whatunga, tae atu ki te whirihoranga papangaahi me nga ture ararere, hei karo i nga paraka me te tere ake te tuku mēra.
  3. Whirihorahia nga tawhā tūtira karere kia rite ki te uta o te tūmau. Ka uru pea tenei ki te whakarite i te rahinga o te tutira me nga wa waahi.
  4. Whakaarohia nga otinga i korerohia i roto i tenei tuhinga i mua. I ia wa ka arotauhia te papaunga raraunga tūmau mēra hei whakapai ake i te mahi, whakamahia nga tikanga keteroki kia tere ake te rapu raraunga me te tukatuka, penei i nga patai DNS.
  5. Mēnā ka tūtaki tonu te tūmau mēra i te kawenga nui, whakaarohia ngā kōwhiringa āwhata, pērā i te whakamahi i te kāhui tūmau mēra, otinga kapua ranei.

Opaniraa

Ko te pikinga o te utaina o te tūmau ka pa ki te tere o te utaina o te paetukutuku, i te mutunga ka pa ki te wheako kaiwhakamahi me te ingoa i roto i nga miihini rapu. No reira, ko te whakahaere tika i tenei kawenga ka whai waahi nui ki te whakapumau i te mahi tonu o te rauemi me te whakanui ake i tona urunga atu mo nga manuhiri.

❮ Tuhinga o mua Tūmau Uta Tātaritanga
Tuhinga ka whai mai ❯ Certbot: Tāuta Tiwhikete Kia Whakamuna

Patai mai mo VPS

Kei te reri tonu matou ki te whakautu i o patai i nga wa katoa o te ao, o te po ranei.