2021-09-10 04:30:02 -07:00
<!DOCTYPE html>
<!-- [if IE 8]><html class="no - js lt - ie9" lang="en" > <![endif] -->
<!-- [if gt IE 8]><! --> < html class = "no-js" lang = "en" > <!-- <![endif] -->
< head >
< meta charset = "utf-8" >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< link rel = "canonical" href = "https://blog.trentsonlinedocs.xyz/posts/apache-virtual-hosts/" >
< link rel = "shortcut icon" href = "../../img/favicon.ico" >
< title > Apache Virtual Hosts - Trent's Blog< / title >
< link rel = "stylesheet" href = "https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700" / >
< link rel = "stylesheet" href = "../../css/theme.css" / >
< link rel = "stylesheet" href = "../../css/theme_extra.css" / >
< link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" / >
< link href = "../../extra.css" rel = "stylesheet" / >
< script >
// Current page data
var mkdocs_page_name = "Apache Virtual Hosts";
var mkdocs_page_input_path = "posts/apache-virtual-hosts.md";
var mkdocs_page_url = "/posts/apache-virtual-hosts/";
< / script >
< script src = "../../js/jquery-2.1.1.min.js" defer > < / script >
< script src = "../../js/modernizr-2.8.3.min.js" defer > < / script >
< script src = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js" > < / script >
< script > hljs . initHighlightingOnLoad ( ) ; < / script >
< / head >
< body class = "wy-body-for-nav" role = "document" >
< div class = "wy-grid-for-nav" >
< nav data-toggle = "wy-nav-shift" class = "wy-nav-side stickynav" >
< div class = "wy-side-scroll" >
< div class = "wy-side-nav-search" >
< a href = "../.." class = "icon icon-home" > Trent's Blog< / a >
< div role = "search" >
< form id = "rtd-search-form" class = "wy-form" action = "../../search.html" method = "get" >
< input type = "text" name = "q" placeholder = "Search docs" title = "Type search term here" / >
< / form >
< / div >
< / div >
2020-12-19 21:16:22 -08:00
2021-09-10 04:30:02 -07:00
< div class = "wy-menu wy-menu-vertical" data-spy = "affix" role = "navigation" aria-label = "main navigation" >
< p class = "caption" > < span class = "caption-text" > RSS< / span > < / p >
< ul >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../rss/" > RSS< / a >
< / li >
< / ul >
< p class = "caption" > < span class = "caption-text" > Links< / span > < / p >
< ul >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../links/" > Links< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://trentpalmer.org" > TrentReads< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://blog.trentpalmer.org" > AttentionSpanHistory< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://github.com/TrentSPalmer" > GitHub< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://twitter.com/boringtrent" > Twitter< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://www.facebook.com/trentspalmer" > Facebook< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://docs.trentsonlinedocs.xyz/" > TrentDocs< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://trentsonlinedocs.xyz/hugo-themes-report/hugo-themes-report.html" > HugoThemesReport< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://play.google.com/store/apps/details?id=org.trentpalmer.libre_gps_parser" > LibreGpsParser< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://concise-pdx.com/" > ConcisePDX< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://trentspalmer.github.io/fcc-challenges/" > FreeCodeCampChallenges< / a >
< / li >
< li class = "toctree-l1" > < a class = "" href = "https://trentpalmer.work/6a57bbe24d8244289610bf57533d6c6f/" > DeviceLayout< / a >
< / li >
< / ul >
< p class = "caption" > < span class = "caption-text" > Posts< / span > < / p >
< ul class = "current" >
< li class = "toctree-l1" > < a class = "reference internal" href = "../trents-favorite-podcasts/" > Trent's Favorite Podcasts< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../test-qr-svg-django/" > Test QRCODE Svg in Django< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../prosody-photo-uploads/" > Prosody Photo Uploads< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../xmpp-apt-notifications/" > Xmpp Apt Notifications< / a >
< / li >
< li class = "toctree-l1 current" > < a class = "reference internal current" href = "./" > Apache Virtual Hosts< / a >
< ul class = "current" >
< / ul >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../sendxmpp-handler-for-python-logging/" > SENDXMPPHandler for Python Logging< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../instructions-for-tethering-from-phone/" > Instructions For Tethering From Phone< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../lmde4-custom-partitions-disk-encryption/" > LMDE4 Custom Partitions Disk Encryption< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../linux-move-cursor-with-keyboard/" > Linux Move Cursor With Keyboard< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../simplified-raspberry-streaming/" > Simplified Raspberry Streaming< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../clear-linux-encrypted-xfs-root/" > Clear Linux Encrypted xfs Root< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../clear-linux-guest-virt-manager/" > Clear Linux Guest Virt Manager< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../faster-partitioning-with-sgdisk/" > Faster Partitioning With sgdisk< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../lmde3-xfs-full-disk-encryption/" > LMDE3 xfs Full Disk Encryption< / a >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../rewrite-hugo-themes-report-in-python/" > Rewrite Hugo Themes Report in Python< / a >
< / li >
< / ul >
< / div >
< / div >
< / nav >
2021-09-02 13:03:42 -07:00
2021-09-10 04:30:02 -07:00
< section data-toggle = "wy-nav-shift" class = "wy-nav-content-wrap" >
2021-09-02 13:03:42 -07:00
2021-09-10 04:30:02 -07:00
< nav class = "wy-nav-top" role = "navigation" aria-label = "top navigation" >
< i data-toggle = "wy-nav-top" class = "fa fa-bars" > < / i >
< a href = "../.." > Trent's Blog< / a >
2021-04-19 19:26:40 -07:00
< / nav >
2021-09-02 14:05:12 -07:00
2021-09-10 04:30:02 -07:00
< div class = "wy-nav-content" >
< div class = "rst-content" >
< div role = "navigation" aria-label = "breadcrumbs navigation" >
< ul class = "wy-breadcrumbs" >
< li > < a href = "../.." > Docs< / a > » < / li >
2021-09-02 14:05:12 -07:00
2021-09-10 04:30:02 -07:00
< li > Posts » < / li >
2021-09-02 14:05:12 -07:00
2021-09-10 04:30:02 -07:00
< li > Apache Virtual Hosts< / li >
< li class = "wy-breadcrumbs-aside" >
2021-09-02 14:05:12 -07:00
< / li >
2020-12-19 21:16:22 -08:00
< / ul >
2021-09-10 04:30:02 -07:00
< hr / >
< / div >
< div role = "main" >
< div class = "section" >
2020-12-19 21:16:22 -08:00
< p > date: 2020-12-20< / p >
< h2 id = "use-virtual-hosts" > < strong > Use Virtual Hosts< / strong > < / h2 >
< p > This is a very useful way to keep your server organized.< / p >
< h2 id = "virtual-hosts-on-your-lan" > < strong > Virtual Hosts On Your Lan< / strong > < / h2 >
< p > You can practice on your Lan.< / p >
< h3 id = "setting-up-dns-on-your-lan" > Setting up DNS on your Lan< / h3 >
< p > For instance, if your router is running < code > dnsmasq< / code > , this may be as simple
as describing the virtual hosts in < code > /etc/hosts< / code > on the router.
< div class = "highlight" > < pre > < span > < / span > < code > < span class = "go" > 192.168.1.101 blog.devbox blogstatic.devbox< / span >
< / code > < / pre > < / div > < / p >
< h3 id = "heres-an-example-reverse-proxy-for-a-flask-blog-on-your-lan" > Here's An Example Reverse Proxy for A Flask Blog On Your Lan< / h3 >
< div class = "highlight" > < pre > < span > < / span > < code > < span class = "c" > # /etc/apache2/sites-enabled/blog.devbox.conf< / span >
< span class = "nt" > < VirtualHost< / span > < span class = "s" > *:80< / span > < span class = "nt" > > < / span >
< span class = "nb" > ServerName< / span > blog.devbox
< span class = "c" > # dont' block LetsEncrypt< / span >
< span class = "c" > # ProxyPass " /.well-known" ! ... not needed on your Lan< / span >
< span class = "c" > # don' t block /var/www/html/favicon.ico< / span >
< span class = "nb" > ProxyPass< / span > < span class = "s2" > " /favicon.ico" < / span > !
< span class = "nb" > ProxyPass< / span > < span class = "s2" > " /" < / span > < span class = "s2" > " http://127.0.0.1:8000/" < / span >
< span class = "nb" > ProxyPassReverse< / span > < span class = "s2" > " /" < / span > < span class = "s2" > " http://127.0.0.1:8000/" < / span >
< span class = "nb" > ErrorLog< / span > ${APACHE_LOG_DIR}/error.log
< span class = "nb" > CustomLog< / span > ${APACHE_LOG_DIR}/access.log combined
< span class = "nt" > < /VirtualHost> < / span >
< / code > < / pre > < / div >
< h3 id = "heres-an-example-for-a-static-blog-on-your-lan" > Here's An Example for A Static Blog On Your Lan< / h3 >
< div class = "highlight" > < pre > < span > < / span > < code > < span class = "c" > # /etc/apache2/sites-enabled/blogstatic.devbox.conf< / span >
< span class = "nt" > < VirtualHost< / span > < span class = "s" > *:80< / span > < span class = "nt" > > < / span >
< span class = "nb" > ServerName< / span > blogstatic.devbox
< span class = "nb" > DocumentRoot< / span > < span class = "sx" > /var/www/html/blogstatic/site< / span >
< span class = "nb" > ErrorLog< / span > ${APACHE_LOG_DIR}/error.log
< span class = "nb" > CustomLog< / span > ${APACHE_LOG_DIR}/access.log combined
< span class = "nt" > < /VirtualHost> < / span >
< / code > < / pre > < / div >
< h2 id = "wan-deployment" > < strong > Wan Deployment< / strong > < / h2 >
< h3 id = "set-up-dns" > Set up DNS< / h3 >
< p > Log into your dns provider and create records< / p >
< ul >
< li > A record for < strong > blog.example.com< / strong > pointing to your ipv4 address< / li >
< li > AAAA record for < strong > blog.example.com< / strong > pointing to your ipv6 address< / li >
< li > A record for < strong > blogstatic.example.com< / strong > pointing to your ipv4 address< / li >
< li > AAAA record for < strong > blogstatic.example.com< / strong > pointing to your ipv6 address< / li >
< / ul >
< h3 id = "start-with-virtual-hosts-for-http" > Start With Virtual Hosts for HTTP< / h3 >
< p > You don't need to create virtual hosts for SSL configuration, because
CertBot will automatically do that for you.< / p >
< h4 id = "reverse-proxy" > Reverse Proxy< / h4 >
< div class = "highlight" > < pre > < span > < / span > < code > < span class = "c" > # /etc/apache2/sites-enabled/blog.example.com.conf< / span >
< span class = "nt" > < VirtualHost< / span > < span class = "s" > *:80< / span > < span class = "nt" > > < / span >
< span class = "nb" > ServerName< / span > blog.example.com
< span class = "c" > # dont' block LetsEncrypt< / span >
< span class = "nb" > ProxyPass< / span > < span class = "s2" > " /.well-known" < / span > !
< span class = "c" > # don' t block /var/www/html/favicon.ico< / span >
< span class = "nb" > ProxyPass< / span > < span class = "s2" > " /favicon.ico" < / span > !
< span class = "nb" > ProxyPass< / span > < span class = "s2" > " /" < / span > < span class = "s2" > " http://127.0.0.1:8000/" < / span >
< span class = "nb" > ProxyPassReverse< / span > < span class = "s2" > " /" < / span > < span class = "s2" > " http://127.0.0.1:8000/" < / span >
< span class = "nb" > ErrorLog< / span > ${APACHE_LOG_DIR}/error.log
< span class = "nb" > CustomLog< / span > ${APACHE_LOG_DIR}/access.log combined
< span class = "nt" > < /VirtualHost> < / span >
< / code > < / pre > < / div >
< h4 id = "static-site" > Static Site< / h4 >
< div class = "highlight" > < pre > < span > < / span > < code > < span class = "c" > # /etc/apache2/sites-enabled/blogstatic.example.com.conf< / span >
< span class = "nt" > < VirtualHost< / span > < span class = "s" > *:80< / span > < span class = "nt" > > < / span >
< span class = "nb" > ServerName< / span > blogstatic.example.com
< span class = "nb" > DocumentRoot< / span > < span class = "sx" > /var/www/html/blogstatic/site< / span >
< span class = "nb" > ErrorLog< / span > ${APACHE_LOG_DIR}/error.log
< span class = "nb" > CustomLog< / span > ${APACHE_LOG_DIR}/access.log combined
< span class = "nt" > < /VirtualHost> < / span >
< / code > < / pre > < / div >
< h3 id = "get-letsencrypt-certs" > Get LetsEncrypt Certs< / h3 >
< p > < div class = "highlight" > < pre > < span > < / span > < code > < span class = "go" > certbot --apache -d blog.example.com -d blogstatic.example.com< / span >
< / code > < / pre > < / div >
Certbot will create and enable new conf files with SSL encryption configured,
and will modify your http conf files with redirections to https.< / p >
< / div >
2021-04-19 19:26:40 -07:00
< / div >
2021-09-10 04:30:02 -07:00
< footer >
2020-12-19 21:16:22 -08:00
2021-09-10 04:30:02 -07:00
< div class = "rst-footer-buttons" role = "navigation" aria-label = "footer navigation" >
2020-12-19 21:16:22 -08:00
2021-09-10 04:30:02 -07:00
< a href = "../sendxmpp-handler-for-python-logging/" class = "btn btn-neutral float-right" title = "SENDXMPPHandler for Python Logging" > Next < span class = "icon icon-circle-arrow-right" > < / span > < / a >
2020-12-19 21:16:22 -08:00
2021-09-10 04:30:02 -07:00
< a href = "../xmpp-apt-notifications/" class = "btn btn-neutral" title = "Xmpp Apt Notifications" > < span class = "icon icon-circle-arrow-left" > < / span > Previous< / a >
2021-09-02 13:52:37 -07:00
2021-09-10 04:30:02 -07:00
< / div >
< hr / >
< div role = "contentinfo" >
<!-- Copyright etc -->
2021-09-02 13:52:37 -07:00
2020-12-19 21:16:22 -08:00
< / div >
2021-09-10 04:30:02 -07:00
Built with < a href = "https://www.mkdocs.org/" > MkDocs< / a > using a < a href = "https://github.com/snide/sphinx_rtd_theme" > theme< / a > provided by < a href = "https://readthedocs.org" > Read the Docs< / a > .
2020-12-19 21:16:22 -08:00
< / footer >
2021-09-10 04:30:02 -07:00
< / div >
< / div >
< / section >
< / div >
< div class = "rst-versions" role = "note" aria-label = "versions" >
< span class = "rst-current-version" data-toggle = "rst-current-version" >
2021-04-19 19:26:40 -07:00
2020-12-19 21:16:22 -08:00
2021-09-10 04:30:02 -07:00
< span > < a href = "../xmpp-apt-notifications/" style = "color: #fcfcfc" > « Previous< / a > < / span >
2020-12-19 21:16:22 -08:00
2021-09-10 04:30:02 -07:00
< span > < a href = "../sendxmpp-handler-for-python-logging/" style = "color: #fcfcfc" > Next » < / a > < / span >
< / span >
< / div >
< script > var base _url = '../..' ; < / script >
< script src = "../../js/theme_extra.js" defer > < / script >
< script src = "../../js/theme.js" defer > < / script >
< script src = "../../search/main.js" defer > < / script >
< script defer >
window.onload = function () {
SphinxRtdTheme.Navigation.enable(true);
};
< / script >
< / body >
< / html >