
我正在使用一個看起來有點預設的 VirtualHost 文件,該文件是我不久前配置的(在我對這個東西的工作原理有很多了解之前),並且我不太確定我應該保留什麼。我不想只是嘗試一些東西,因為設置一個包含所有這些東西的虛擬機會很麻煩,並且當前配置處於生產環境中,因此試錯並不是真正的選擇。這是文件,為了保護無辜者而更改了名稱:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.my.hostname
ServerAlias my.hostname
DocumentRoot /var/www/mysite
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/mysite>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog ${APACHE_LOG_DIR}/access.log combined
LogFormat "%t %T/%D \"%r\" %>s %b" mysitelog
CustomLog ${APACHE_LOG_DIR}/mysite.access.log mysitelog
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
我對此的疑問是:
我該擺脫這個
<Directory />
障礙嗎?它是$APACHE_HOME/conf.d/security
透過註釋「這目前破壞了某些 Web 應用程式 Debian 軟體包附帶的配置」來指定的。我應該取消該版本的註釋並從我的虛擬主機中刪除該版本嗎?這只不過是 PHP,所以我猜沒有理由保留 cgi 區塊和別名。
我想我也可以擺脫這些
doc
東西。我什至不太確定它的用途,所以如果你能解釋它在“正常”設定中的用途,那就加分(不是真的)。
因此,假設我的想法是正確的,我的新虛擬主機檔案可能如下所示:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.my.hostname
ServerAlias my.hostname
DocumentRoot /var/www/mysite
<Directory /var/www/mysite>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog ${APACHE_LOG_DIR}/access.log combined
LogFormat "%t %T/%D \"%r\" %>s %b" mysitelog
CustomLog ${APACHE_LOG_DIR}/mysite.access.log mysitelog
</VirtualHost>
任何其他提示都非常受歡迎。謝謝!如果需要我的配置的更多信息,請告訴我!
答案1
我該擺脫這個
<Directory />
障礙嗎?
當然!這絕對是您可以在伺服器層級而不是虛擬主機中處理的事情。
這只不過是 PHP,所以我猜沒有理由保留 cgi 區塊和別名。
用核武攻擊它。
我想我也可以擺脫文檔的東西。
用核武攻擊它。它就在那裡,因此您可以使用新安裝的 Web 伺服器來瀏覽系統文件。這是一個可愛的例子,但在我看來,它確實不屬於預設設定檔。
在您建議的設定檔上:看起來不錯!我提出的一個建議是,如果您不使用文件AllowOverride All
,則將目錄塊中的更改為- 如果您正在使用文件,我建議將它們刪除並將其配置拉入目錄塊。 (AllowOverride None
.htaccess
.htaccess
請參閱此處了解我為什麼這麼說的詳細信息)