VirtualHosts无法正常工作(Mod_proxy,Proxmox)

时间:2012-01-09 21:03:06

标签: apache2 virtualhost mod-proxy

对于初学者,我使用Proxmox虚拟化多台机器。 现在我希望我的主机根据服务器名相应地重定向流量。 我让设置工作了一次,但现在不知何故它将无法正常工作。

我的默认主持人:

00_proxmox_domain_com.conf

NameVirtualHost *:80
<VirtualHost *:80>
ServerName proxmox.domain.com
ServerName *.proxmox.domain.com
#RewriteLog "/root/rewrite.log"
#RewriteLogLevel 10
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
RewriteCond %{REQUEST_URI} !^/nrd/
RewriteCond %{REQUEST_URI} !^/images/
RewriteCond %{REQUEST_URI} !^/css/
RewriteCond %{REQUEST_URI} !^/javascript/
RewriteCond %{REQUEST_URI} !^/vncterm/
RewriteCond %{REQUEST_URI} !^/.*\.js$
RewriteCond %{REQUEST_URI} !^/login.pl$
RewriteCond %{HTTP_HOST} ^proxmox\.domain\.com$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [L,R]
</VirtualHost>

然后我有几个类似的虚拟主机,(目前只激活了这个) 这应该将访问者发送到IP地址为192.168.1.13的虚拟服务器上的PHPMyAdmin

02_pma_domain_com.conf

<VirtualHost *:80>
ServerName pma.domain.com
ServerName *.pma.domain.com

ProxyRequests Off

ProxyPreserveHost On

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass / http://192.168.1.13/
ProxyPassReverse / http://192.168.1.13/
</VirtualHost>

还有Proxmox虚拟主机文件

pve.conf

<IfModule mpm_prefork_module>
StartServers 2
MinSpareServers 1 
MaxSpareServers 2
MaxClients          50
MaxRequestsPerChild 30
</IfModule>

  ServerName localhost
  ServerSignature Off
  ServerTokens Prod
  ServerAdmin root
  AddDefaultCharset On

  # Hint: Ajax use KeepAlive, which in effect disables MaxRequestsPerChild,
  # so we need to disable KeepAlive to prevent exhaustive memory usage, or
  # at least make sure that periodic updaters interval > KeepAliveTimeout 
  KeepAlive Off

  DocumentRoot /usr/share/pve-manager/root
  <Directory />
Options FollowSymLinks
AllowOverride None
  </Directory>

  <Directory /usr/share/pve-manager/root>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
  </Directory>

  ErrorLog /var/log/apache2/error.log

  LogLevel warn

  # do not log access to our ajax services
  SetEnvIf Request_URI "^/ws/" dontlog

  CustomLog /var/log/apache2/access.log combined env=!dontlog 

  Alias /images/  /usr/share/pve-manager/images/
  Alias /css/ /usr/share/pve-manager/css/
  Alias /javascript/ /usr/share/javascript/
  Alias /vncterm/ /usr/share/vncterm/

  # avoid authentication when accessing favicon
  Alias /favicon.ico /usr/share/pve-manager/images/favicon.ico

  PerlModule Embperl
  EMBPERL_SESSION_ARGS "config=DB_File Lock=Semaphore"

  AddType text/html .epl

  PerlRequire /usr/share/pve-manager/root/startup.pl

  PerlSetVar PVESatisfy any     
  PerlSetVar PVEPath /  
  PerlSetVar PVELoginScript /login.pl

  PerlTransHandler PVE::URLRewrite

  Alias /nrd/ /__no_real_dir__/

  <Directory "/usr/share/pve-manager/root">
  AuthType PVE::AuthCookieHandler
  AuthName PVE
  PerlSetVar PVECookieName PVEAuthCookie
  #PerlSetVar AuthCookieDebug 5

  PerlAuthenHandler PVE::AuthCookieHandler->authenticate
  PerlAuthzHandler PVE::AuthCookieHandler->authorize

  require group root

  DirectoryIndex index.htm index.pl

  <FilesMatch ".*\.htm$">
EMBPERL_APPNAME PVE
    EMBPERL_SYNTAX EmbperlBlocks
    EMBPERL_OBJECT_BASE base.epl
EMBPERL_INPUT_ESCMODE 0
EMBPERL_ESCMODE 0
    SetHandler  perl-script
    PerlHandler Embperl::Object
    Options     ExecCGI
  </FilesMatch>
  <FilesMatch ".*\.epl$">
    Order allow,deny
    Deny From all
  </FilesMatch>
  <FilesMatch ".*\.pl$">
    SetHandler perl-script
PerlHandler ModPerl::Registry
    Options +ExecCGI
  </FilesMatch>

</Directory>

<Location /nrd/LOGIN>
  AuthType PVE::AuthCookieHandler
  AuthName PVE
  PerlSetVar PVECookieName PVEAuthCookie
  #PerlSetVar AuthCookieDebug 5
  SetHandler perl-script
  PerlHandler PVE::AuthCookieHandler->login
</Location>

<Location /ws/>
  SetHandler perl-script
  PerlHandler $PVE::HTMLServices::Obj->handler
</Location>

<VirtualHost *:443>
SSLEngine on
SSLProtocol all -SSLv2
SSLCertificateFile /etc/pve/pve-ssl.pem
SSLCertificateKeyFile /etc/pve/pve-ssl.key

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

</VirtualHost>

如果您发现明显错误,请告诉我。

如果您正在安装proxmox,那么如果你能给我你的pve.conf会有所帮助 如果你有虚拟主机工作,那么其中一个文件将是最受欢迎的。

我已经尝试了几个方法来解决问题,没有任何影响。

1 个答案:

答案 0 :(得分:0)

找到它,感谢: Apache 2.2 ignoring VirtualDocumentRoot VirtualHosts?

应该只有一个ServerName,它不能包含任何通配符, 你应该使用ServerAlias;)