Блокировка доступа с имени сервера - PullRequest
0 голосов
/ 29 мая 2020

Привет, я укрепляю сайт WordPress, который использует Apache в качестве веб-сервера. Я хочу заблокировать доступ с servername.admin.company.com. Я попытался отредактировать HTACCESS для другого ответа, который я видел здесь, но сайт начал 500 с https://domainname.com. Существует масса проблем с безопасностью, и мы решили, что лучший способ справиться с этим - просто полностью заблокировать доступ, поскольку никому действительно не нужно получать к нему доступ таким образом.

Вот мой файл vhosts:

'  <Directory "/var/www/directory">
    AllowOverride All
    Options -Indexes +FollowSymLinks
    Require all granted
    Require not host servername.admin.company.com
  </Directory>
DirectoryIndex index.php index.html


<VirtualHost *:80>
  ServerName site.com
  ServerAlias www.site.com

  DocumentRoot "/var/www/directory"

  # Enable HSTS (tell browsers to use only HTTP)
  Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload;"

  <Directory "/var/www/html">
    AllowOverride All
    Options -Indexes +FollowSymLinks
    Require all granted
  </Directory>

  RewriteEngine on
  RewriteRule "^(.*/)?\.git/" - [F,L]
  RedirectMatch 404 /\.git

</VirtualHost>



<VirtualHost *:80>
  ServerName business.site.com
  ServerAlias subdomain.site.com
 ServerAlias www.business.site.com

  DocumentRoot "/var/www/directory"

  # Enable HSTS (tell browsers to use only HTTP)
  Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload;"

  <Directory "/var/www/site">
    AllowOverride All
    Options -Indexes +FollowSymLinks
    Require all granted
  </Directory>

  RewriteEngine on
  RewriteRule "^(.*/)?\.git/" - [F,L]
  RedirectMatch 404 /\.git

  CustomLog /var/log/httpd/site-requests.log combined
</VirtualHost>



<VirtualHost *:80>
  ServerName business.site.com
  ServerAlias directory.site.com
 ServerAlias www.subfolder.site.com

  DocumentRoot "/var/www/sitefolder"

  # Enable HSTS (tell browsers to use only HTTP)
  Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload;"

  <Directory "/var/www/sitefolder">
    AllowOverride All
    Options -Indexes +FollowSymLinks
    Require all granted
  </Directory>

  RewriteEngine on
  RewriteRule "^(.*/)?\.git/" - [F,L]
  RedirectMatch 404 /\.git

  CustomLog /var/log/httpd/sitefolder-requests.log combined
  ErrorLog /var/log/httpd/sitefolder-error.log

</VirtualHost>

'

1 Ответ

0 голосов
/ 29 мая 2020

Вы можете добиться этого разными способами, iptables, .htaccess, и c.

Пожалуйста, посетите этот URL, все, что вам нужно сделать, хорошо документировано там:

https://httpd.apache.org/docs/2.4/en/howto/access.html

Надеюсь, это вам поможет.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...