时间:2023-07-14 08:03:01 | 来源:网站运营
时间:2023-07-14 08:03:01 来源:网站运营
Apache服务器VirtualHost常用配置:Apache服务器中的VirtualHost用来定义虚拟主机,我们可以在一个VirtualHost中定义一个项目(网站),也可以使用反向代理的方式定义多个项目(即一个域名之下多个子项目)。以下总结Apache服务器VirtualHost常用配置。<VirtualHost *:80> DocumentRoot "/var/www/html" ServerName www.jkdev.cn</VirtualHost>
<VirtualHost *:80> DocumentRoot "/var/www/html" ServerName localhost <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride All Require all granted ErrorDocument 404 https://www.jkdev.cn/404.html </Directory></VirtualHost>
<VirtualHost _default_:443> DocumentRoot "/var/www/html" ServerName hook.jkdev.cn SSLEngine on SSLCertificateFile /etc/ssl/2_hook.jkdev.cn.crt SSLCertificateKeyFile /etc/ssl/3_hook.jkdev.cn.key SSLCertificateChainFile /etc/ssl/1_root_bundle.crt <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride All Require all granted ErrorDocument 404 https://www.jkdev.cn/404.html </Directory></VirtualHost>
<VirtualHost _default_:443> ServerName api.jkdev.cn SSLEngine on SSLCertificateFile /etc/ssl/api/2_api.jkdev.cn.crt SSLCertificateKeyFile /etc/ssl/3_api.jkdev.cn.key SSLCertificateChainFile /etc/ssl/1_root_bundle.crt ProxyPreserveHost On ProxyRequests Off ProxyPass /v2 http://localhost:92/ ProxyPass /v1 http://localhost:91/ ProxyPass / http://localhost:90/ ProxyPassReverse /v2 http://localhost:92/ ProxyPassReverse /v1 http://localhost:91/ ProxyPassReverse / http://localhost:90/</VirtualHost>
<VirtualHost *:80> ServerName jkdev.cn #redirect RewriteEngine on RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^(.*)?$ https://%{SERVER_NAME}$1 [L,R]</VirtualHost>
关键词:配置,服务