• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Apache2 IPv6 Virtual Host Configuration (Ubuntu Server)

By Abhishek Ghosh September 7, 2018 3:53 pm Updated on September 7, 2018

Apache2 IPv6 Virtual Host Configuration (Ubuntu Server)

Advertisement

Most Important Part of Apache Web Server is Virtual Host. Commonly we show IPv4 configuration for the beginners. Here is Apache2 IPv6 Virtual Host Configuration For Ubuntu Server. For this guide, we are assuming that the readers are using Ubuntu 16.04 or Ubuntu 18.04 and has followed our guide to install Apache on Ubuntu 18.04. Our guide is different from gross guides on web as we use Ondřej Surý’s PPA and assume that the readers using SSL/TLS with HSTS.

 

Sample Apache2 IPv6 Virtual Host Configuration For Ubuntu Server

 

Update and upgrade Ubuntu :

Vim
1
2
apt update -y
apt upgrade -y

In case, you have not installed Apache2, then install it after adding Ondřej Surý’s PPA :

Advertisement

---

Vim
1
2
3
4
5
6
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/apache2
# hit enter/return key to accept
apt update -y
apt upgrade -y
sudo apt install apache2

Normally we activate these modules and restart Apache :

Vim
1
2
3
4
5
6
a2enmod http2
systemctl restart apache2
a2enmod ssl
systemctl restart apache2
a2ensite default-ssl
systemctl restart apache2

Normally for IPv6 we go to /etc/apache2/sites-available/ and check the files :

Vim
1
2
cd /etc/apache2/sites-available/
ls -al

Usually there are two files – 000-default.conf and default-ssl.conf. For IPv4 we edit them. Apache’s another important file is :

Vim
1
/etc/apache2/apache2.conf

We have to check for Listen directive. We can cat and grep the two files to check Listen directive :

Vim
1
2
3
cat /etc/apache2/apache2.conf | grep "Listen"
cat /etc/apache2/sites-available/000-default.conf | grep "Listen"
cat /etc/apache2/sites-available/default-ssl.conf | grep "Listen"

We can check which ports and type of IP our Apache is listening by running :

Vim
1
netstat -lnptu |grep "apache2\W*$"

That will return output like this :

Vim
1
2
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      4889/apache2
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      4889/apache2

Apache2 IPv6 Virtual Host Configuration Ubuntu Server

That means Apache is not listening to IPv6. It is listening only to port 80 and port 443 of IPv4.

Usually by default there is no Listen directive. Instead we write in this way in /etc/apache2/sites-available/default-ssl.conf file :

Vim
1
2
3
4
5
6
7
8
<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin webmaster@thecustomizewindows.com
 
                DocumentRoot /var/www/html
                ErrorLog ${APACHE_LOG_DIR}/error.log
...
...

The string _default_ is used with IP virtual hosting to catch unmatched IP addresses. That is good for IPv4 but for IPv6 we need to mention single specific IP for a particular site, otherwise it will open wide door to the script kiddies. IPv6 has special considerations, which are mentioned on official documentation :

Vim
1
https://httpd.apache.org/docs/2.4/bind.html#ipv6

That default virtual host example configuration above need to be changed. If our IPv4 is 12.13.14.15 and IPv6 selected is fd13:01ec:a560:534f::50, then we can add listen directive to both ports for both IPv4 and IPv6 :

Vim
1
2
3
4
Listen [fd13:01ec:a560:534f::50]:80
Listen [fd13:01ec:a560:534f::50]:443
Listen 12.13.14.15:80
Listen 12.13.14.15:443

We can add the above stanza to /etc/apache2/apache2.conf file. If we add Listen directive to virtual host file like :

Vim
1
cat /etc/apache2/sites-available/default-ssl.conf

That becomes complex to maintain with just one site on server. It becomes highly complicated for 4+ virtual host files on the server.

And we will write the virtual host files (like /etc/apache2/sites-available/default-ssl.conf) in this way :

/etc/apache2/sites-available/default-ssl.conf
Vim
1
2
3
4
5
6
7
8
<IfModule mod_ssl.c>
        <VirtualHost [fd13:01ec:a560:534f::50]:443 12.13.14.15:443>
                ServerAdmin webmaster@thecustomizewindows.com
 
                DocumentRoot /var/www/html
                ErrorLog ${APACHE_LOG_DIR}/error.log
...
...

Then we can do a config test :

Vim
1
sudo apache2ctl configtest

The above system of configuration will decrease the headache during maintenance. Thereafter we can restart Apache :

Vim
1
service apache2 restart

Then check what Apache is listening to :

Vim
1
netstat -lnptu |grep "apache2\W*$"

We will get something like :

Vim
1
tcp        0      0 fd13:01ec:a560:534f::50:443     :::*                        LISTEN      4473/apache2

 

Conclusion

 

For IPv6, we need to determine the specific IP we are going to use. Then add Listen directive to /etc/apache2/apache2.conf file. Then edit virtual host files like /etc/apache2/sites-available/default-ssl.conf. With all default settings, your server may respond to a specific IPv6 address, but that technically not perfect for various reasons.

Tagged With apache2 ipv6 , adding ipv6 to apache2 sitesenanbled , ubuntui apache2 listen to ipv6 and ipv4 , ipv6 apache ubuntu , cd /etc/apache2/sites-available/ , apache2 ipv6 listen , apache ipv6 virtual host in ubuntu , apache ipv6 konfigurieren ubuntu 18 04 , apache 2 bind ipv6 address , websites on apache server uses ipv6
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Apache2 IPv6 Virtual Host Configuration (Ubuntu Server)

  • How To Install Apache2 on Ubuntu 18.04 With Let’s Encrypt, HTTP/2, HSTS

    Here is Detailed Guide on How To Install Apache2 on Ubuntu 18.04 With Let’s Encrypt, HTTP/2, HSTS With Commands and Configurations For Most Secured Setup.

  • How To Add IPv6 to IPv4 Server With Nginx Reverse Proxy

    Some Dedicated Server May Not Have IPv6. Here is How To Add IPv6 to IPv4 Server With Nginx Reverse Proxy and Cloud Server Instance With IPv6.

  • sysctl.conf Tweaking In OpenVZ Virtual Server Instance

    OpenVZ Kernel Offers A Conservative and Stable Kernel. Here Is Some Information On sysctl.conf Tweaking In OpenVZ Virtual Server Instance.

  • Nginx IPV6 Reverse Proxy With SSL To Add IPV6 (Full Guide + Configs)

    We Discussed Full Guide On Nginx IPV6 Reverse Proxy With SSL To Add IPV6 To IPV4 Only Servers. Here Is Every Basics And Full Configuration.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is Hardware Security Module (HSM)September 30, 2023
  • Transducer Technologies of HeadphonesSeptember 28, 2023
  • What is Analog-to-Digital Converter (ADC)September 27, 2023
  • Comparison of Tube Amplifiers and SemiconductorsSeptember 26, 2023
  • What is a Digital-to-Analog Converter (DAC)September 25, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy