Virtual Host And Certbot in Raspbian 10: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Line 5: Line 5:
<source lang="bash">
<source lang="bash">
# chorke.{org,com}
# chorke.{org,com}
mkdir -p /etc/chorke/httpd/conf.sites.all.d
mkdir -p /etc/chorke/apache2/conf.sites.all.d
cd /etc/chorke/httpd/conf.sites.all.d
cd /etc/chorke/apache2/conf.sites.all.d


nano 00-dev.chorke.org.conf
nano 00-dev.chorke.org.conf
Line 22: Line 22:


<source lang="bash">
<source lang="bash">
# shahed.{biz}
# shahed.biz
mkdir -p /etc/shahed/httpd/conf.sites.all.d
mkdir -p /etc/shahed/apache2/conf.sites.all.d
cd /etc/shahed/httpd/conf.sites.all.d
cd /etc/shahed/apache2/conf.sites.all.d


nano 00-dev.shahed.biz.conf
nano 03-dev.shahed.biz.conf
nano 00-dev.shahed.biz-le-ssl.conf
nano 03-dev.shahed.biz-le-ssl.conf
</source>
</source>


Line 34: Line 34:
<source lang="bash">
<source lang="bash">
# chorke.{org,com}
# chorke.{org,com}
mkdir -p /etc/chorke/httpd/conf.sites.enable.d
cd /etc/apache2/sites-enabled
cd /etc/chorke/httpd/conf.sites.enable.d
ln -s /etc/chorke/apache2/conf.sites.all.d/00-dev.chorke.org.conf\
      /etc/apache2/sites-enabled/00-dev.chorke.org.conf


ln -s ../conf.sites.all.d/00-dev.chorke.org.conf 00-dev.chorke.org.conf
ln -s /etc/chorke/apache2/conf.sites.all.d/01-api.chorke.org.conf\
ln -s ../conf.sites.all.d/00-dev.chorke.org-le-ssl.conf 00-dev.chorke.org-le-ssl.conf
      /etc/apache2/sites-enabled/01-api.chorke.org.conf


ln -s ../conf.sites.all.d/01-api.chorke.org.conf 01-api.chorke.org.conf
ln -s /etc/chorke/apache2/conf.sites.all.d/01-ihe.chorke.org.conf\
ln -s ../conf.sites.all.d/01-api.chorke.org-le-ssl.conf 01-api.chorke.org-le-ssl.conf
      /etc/apache2/sites-enabled/01-ihe.chorke.org.conf


ln -s ../conf.sites.all.d/01-ihe.chorke.org.conf 01-ihe.chorke.org.conf
ln -s /etc/chorke/apache2/conf.sites.all.d/02-dev.chorke.com.conf\
ln -s ../conf.sites.all.d/01-ihe.chorke.org-le-ssl.conf 01-ihe.chorke.org-le-ssl.conf
      /etc/apache2/sites-enabled/02-dev.chorke.com.conf


ln -s ../conf.sites.all.d/02-dev.chorke.com.conf 02-dev.chorke.com.conf
apache2ctl -t
ln -s ../conf.sites.all.d/02-dev.chorke.com-le-ssl.conf 02-dev.chorke.com-le-ssl.conf
</source>
</source>


<source lang="bash">
<source lang="bash">
# shahed.{biz}
# shahed.biz
mkdir -p /etc/shahed/httpd/conf.sites.enable.d
cd /etc/apache2/sites-enabled
cd /etc/shahed/httpd/conf.sites.enable.d
ln -s /etc/shahed/apache2/conf.sites.all.d/03-dev.shahed.biz.conf\
      /etc/apache2/sites-enabled/03-dev.shahed.biz.conf


ln -s ../conf.sites.all.d/00-dev.shahed.biz.conf 00-dev.shahed.biz.conf
apache2ctl -t
ln -s ../conf.sites.all.d/00-dev.shahed.biz-le-ssl.conf 00-dev.shahed.biz-le-ssl.conf
</source>
</source>
|}
|}
===Enabled HTTPS===
<source lang="bash">
# chorke.org
ln -s /etc/chorke/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 /etc/chorke/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 /etc/chorke/apache2/conf.sites.all.d/01-ihe.chorke.org-le-ssl.conf /etc/apache2/sites-enabled/01-ihe.chorke.org-le-ssl.conf
ln -s /etc/chorke/apache2/conf.sites.all.d/02-dev.chorke.com-le-ssl.conf /etc/apache2/sites-enabled/02-dev.chorke.com-le-ssl.conf
apache2ctl -t
# shahed.biz
ln -s /etc/shahed/apache2/conf.sites.all.d/03-dev.shahed.biz-le-ssl.conf /etc/apache2/sites-enabled/03-dev.shahed.biz-le-ssl.conf
apache2ctl -t
</source>


===Directory Tree===
===Directory Tree===

Revision as of 07:41, 16 November 2019

Apache2

All Sites

# chorke.{org,com}
mkdir -p /etc/chorke/apache2/conf.sites.all.d
cd /etc/chorke/apache2/conf.sites.all.d

nano 00-dev.chorke.org.conf
nano 00-dev.chorke.org-le-ssl.conf

nano 01-api.chorke.org.conf
nano 01-api.chorke.org-le-ssl.conf

nano 01-ihe.chorke.org.conf
nano 01-ihe.chorke.org-le-ssl.conf

nano 02-dev.chorke.com.conf
nano 02-dev.chorke.com-le-ssl.conf
# shahed.biz
mkdir -p /etc/shahed/apache2/conf.sites.all.d
cd /etc/shahed/apache2/conf.sites.all.d

nano 03-dev.shahed.biz.conf
nano 03-dev.shahed.biz-le-ssl.conf

Enabled Sites

# chorke.{org,com}
cd /etc/apache2/sites-enabled
ln -s /etc/chorke/apache2/conf.sites.all.d/00-dev.chorke.org.conf\
      /etc/apache2/sites-enabled/00-dev.chorke.org.conf

ln -s /etc/chorke/apache2/conf.sites.all.d/01-api.chorke.org.conf\
      /etc/apache2/sites-enabled/01-api.chorke.org.conf

ln -s /etc/chorke/apache2/conf.sites.all.d/01-ihe.chorke.org.conf\
      /etc/apache2/sites-enabled/01-ihe.chorke.org.conf

ln -s /etc/chorke/apache2/conf.sites.all.d/02-dev.chorke.com.conf\
      /etc/apache2/sites-enabled/02-dev.chorke.com.conf

apache2ctl -t
# shahed.biz
cd /etc/apache2/sites-enabled
ln -s /etc/shahed/apache2/conf.sites.all.d/03-dev.shahed.biz.conf\
      /etc/apache2/sites-enabled/03-dev.shahed.biz.conf

apache2ctl -t

Enabled HTTPS

# chorke.org
ln -s /etc/chorke/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 /etc/chorke/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 /etc/chorke/apache2/conf.sites.all.d/01-ihe.chorke.org-le-ssl.conf /etc/apache2/sites-enabled/01-ihe.chorke.org-le-ssl.conf
ln -s /etc/chorke/apache2/conf.sites.all.d/02-dev.chorke.com-le-ssl.conf /etc/apache2/sites-enabled/02-dev.chorke.com-le-ssl.conf
apache2ctl -t

# shahed.biz
ln -s /etc/shahed/apache2/conf.sites.all.d/03-dev.shahed.biz-le-ssl.conf /etc/apache2/sites-enabled/03-dev.shahed.biz-le-ssl.conf
apache2ctl -t

Directory Tree

mkdir -p /var/chorke/www;\
cd /var/chorke/www/;p='api dev ihe';\
for s in $p;do d='html docs soft';\
    for f in $d;do w="$s.chorke.org/$f";\
        mkdir -p "$w";\
    done;
done
mkdir -p /var/chorke/www;\
cd /var/chorke/www/;p='dev';\
for s in $p;do d='html docs soft';\
    for f in $d;do w="$s.chorke.com/$f";\
        mkdir -p "$w";\
    done;
done
mkdir -p /var/shahed/www;\
cd /var/shahed/www/;p='dev';\
for s in $p;do d='html docs soft';\
    for f in $d;do w="$s.shahed.biz/$f";\
        mkdir -p "$w";\
    done;
done

Acme Challenges

cd /var/chorke/www/;p='api dev ihe';\
a='.well-known/acme-challenge';\
for s in $p;do w="$s.chorke.org/html";\
    mkdir -p "$w/$a";\
done
cd /var/chorke/www/;p='dev';\
a='.well-known/acme-challenge';\
for s in $p;do w="$s.chorke.com/html";\
    mkdir -p "$w/$a";\
done
cd /var/shahed/www/;p='dev';\
a='.well-known/acme-challenge';\
for s in $p;do w="$s.shahed.biz/html";\
    mkdir -p "$w/$a";\
done
;nano /var/chorke/www/api.chorke.org/html/.htaccess
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{SERVER_NAME} =api.chorke.org [OR]
RewriteCond %{SERVER_NAME} =www.api.chorke.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
f='html docs soft';\
for s in *.chorke.*;do for d in $f;do \
    h="<html>\n<head><title>$s/$d</title></head>\n";
    h="$h<body><h1>Welcome to, $s/$d</h1></body>\n</html>";
    echo -e "$h" >> "$s/$d/index.html";
done;done
f='html docs soft';\
for s in *.shahed.biz;do for d in $f;do \
    h="<html>\n<head><title>$s/$d</title></head>\n";
    h="$h<body><h1>Welcome to, $s/$d</h1></body>\n</html>";
    echo -e "$h" >> "$s/$d/index.html";
done;done
apt -y install apache2 mod_ssl; a2enmod ssl
cd /opt/;git clone https://github.com/certbot/certbot.git
cd /usr/local/bin/;ln -s /opt/certbot/certbot-auto certbot
ln -s /opt/certbot/letsencrypt-auto letsencrypt
letsencrypt     #letsencrypt renew
certbot         #certbot renew