Virtual Host And Certbot in WSL2: Difference between revisions
Jump to navigation
Jump to search
Line 124: | Line 124: | ||
==AutoIndex== | ==AutoIndex== | ||
<source lang="apache" highlight=" | <source lang="apache" highlight="3,4"> | ||
# vim /etc/apache2/mods-enabled/alias.conf | |||
<IfModule alias_module> | <IfModule alias_module> | ||
Alias /icons/ "/mnt/d/usr/share/apache2/icons/" | Alias /icons/ "/mnt/d/usr/share/apache2/icons/" |
Revision as of 22:04, 10 July 2021
a2enmod proxy;\
a2enmod proxy_http;\
a2enmod proxy_balancer;\
a2enmod lbmethod_byrequests;\
service apache2 restart
Config
config locations: mkdir -p /mnt/d/usr/share/apache2/icons mkdir -p /mnt/d/etc/apache2/conf.sites.all.d
virtual site config: touch /mnt/d/etc/apache2/conf.sites.all.d/00-dev.chorke.org{.conf,-le-ssl.conf} touch /mnt/d/etc/apache2/conf.sites.all.d/01-api.chorke.org{.conf,-le-ssl.conf} touch /mnt/d/etc/apache2/conf.sites.all.d/02-dev.chorke.com{.conf,-le-ssl.conf} touch /mnt/d/etc/apache2/conf.sites.all.d/03-dev.shahed.biz{.conf,-le-ssl.conf}
virtual site locations: mkdir -p /mnt/d/var/www/{api,dev}.chorke.org/{docs,html,logs,soft} mkdir -p /mnt/d/var/www/dev.chorke.com/{docs,html,logs,soft} mkdir -p /mnt/d/var/www/dev.shahed.biz/{docs,html,logs,soft} mkdir -p /mnt/d/var/www/{api,dev}.chorke.org/html/.well-known/acme-challenge mkdir -p /mnt/d/var/www/dev.chorke.com/html/.well-known/acme-challenge mkdir -p /mnt/d/var/www/dev.shahed.biz/html/.well-known/acme-challenge
Enable
ln -s /mnt/d/etc/apache2/conf.sites.all.d/00-dev.chorke.org.conf\ /etc/apache2/sites-enabled/00-dev.chorke.org.conf ln -s /mnt/d/etc/apache2/conf.sites.all.d/01-api.chorke.org.conf\ /etc/apache2/sites-enabled/01-api.chorke.org.conf ln -s /mnt/d/etc/apache2/conf.sites.all.d/02-dev.chorke.com.conf\ /etc/apache2/sites-enabled/02-dev.chorke.com.conf ln -s /mnt/d/etc/apache2/conf.sites.all.d/03-dev.shahed.biz.conf\ /etc/apache2/sites-enabled/03-dev.shahed.biz.conf
ln -s /mnt/d/etc/apache2/conf.sites.all.d/00-dev.chorke.org-le-ssl.conf\ /etc/apache2/sites-enabled/00-dev.chorke.org-le-ssl.conf ln -s /mnt/d/etc/apache2/conf.sites.all.d/01-api.chorke.org-le-ssl.conf\ /etc/apache2/sites-enabled/01-api.chorke.org-le-ssl.conf ln -s /mnt/d/etc/apache2/conf.sites.all.d/02-dev.chorke.com-le-ssl.conf\ /etc/apache2/sites-enabled/02-dev.chorke.com-le-ssl.conf ln -s /mnt/d/etc/apache2/conf.sites.all.d/03-dev.shahed.biz-le-ssl.conf\ /etc/apache2/sites-enabled/03-dev.shahed.biz-le-ssl.conf
Virtual Host configuration skipped to avoid redundancy. Please find the config details in Virtual Host And Certbot in Raspbian 10.
Virtual Host
cat <<EOF >> /mnt/d/etc/apache2/conf.sites.all.d/03-dev.shahed.biz.conf
<IfModule mod_proxy.c>
<VirtualHost *:80>
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes Off
ServerAdmin info@shahed.biz
DocumentRoot /mnt/d/var/www/dev.shahed.biz/html
ErrorLog /mnt/d/var/www/dev.shahed.biz/logs/error.log
CustomLog /mnt/d/var/www/dev.shahed.biz/logs/requests.log combined
<Directory "/mnt/d/var/www/dev.shahed.biz/">
AllowOverride None
Require all granted
</Directory>
<Directory "/mnt/d/var/www/dev.shahed.biz/html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
Alias /docs "/mnt/d/var/www/dev.shahed.biz/docs/"
<Directory "/mnt/d/var/www/dev.shahed.biz/docs">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Require all granted
Order Allow,Deny
Allow from all
</Directory>
Alias /logs "/mnt/d/var/www/dev.shahed.biz/logs/"
<Directory "/mnt/d/var/www/dev.shahed.biz/logs">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Require all granted
Order Allow,Deny
Allow from all
</Directory>
Alias /soft "/mnt/d/var/www/dev.shahed.biz/soft/"
<Directory "/mnt/d/var/www/dev.shahed.biz/soft">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Require all granted
Order Allow,Deny
Allow from all
</Directory>
<Proxy *>
Order Allow,Deny
Allow from all
Deny from 10.9.8
</Proxy>
# RewriteEngine on
# RewriteCond %{SERVER_NAME} =dev.shahed.biz [OR]
# RewriteCond %{SERVER_NAME} =www.dev.shahed.biz
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
</IfModule>
EOF
AutoIndex
# vim /etc/apache2/mods-enabled/alias.conf
<IfModule alias_module>
Alias /icons/ "/mnt/d/usr/share/apache2/icons/"
<Directory "/mnt/d/usr/share/apache2/icons">
Options FollowSymlinks
AllowOverride None
Require all granted
</Directory>
</IfModule>
Knowledge
sudo service apache2 restart sudo service redis-server restart