0

I have 2 projects running on different ports - 80 and 8005 on the same server. These ports point to example1.com and example2.com respectively. I installed SSL certificate for example1.com using https://tecadmin.net/install-lets-encrypt-create-ssl-ubuntu/ and it worked. However when I tried for example2.com, I got this error - Problem binding to port 80: Could not bind to IPv4 or IPv6.

I am guessing it needs example2.com to be port 80, is there a workaround this? How can I install a SSL certificate for example2.com?

This is how /sites-enabled look like

example1.com-le-ssl.conf example1.com.conf example2.com.conf

example1.com-le-ssl.conf -

<IfModule mod_ssl.c>
<VirtualHost *:443>

        ServerName example1.com
        ServerAlias www.example1.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/example1/public

        <Directory /var/www/html/example1/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
       </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example1.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example1.com/privkey.pem
</VirtualHost>

</IfModule>

example1.com.conf -

<VirtualHost *:80>

        ServerName example1.com
        ServerAlias www.example1.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/example1/public

        <Directory /var/www/html/example1/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
       </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


RewriteEngine on
RewriteCond %{SERVER_NAME} =example1.com [OR]
RewriteCond %{SERVER_NAME} =www.example1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

example2.com.conf

<VirtualHost *:80>

        ServerName example2.com
        ServerAlias www.example2.com
        #ServerAdmin [email protected]
        DocumentRoot /var/www/html/example2/public

        <Directory /var/www/html/example2/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
        </Directory>
</VirtualHost>

<VirtualHost *:8001>


        ServerName example2.com
        ServerAlias www.example2.com
        #ServerAdmin [email protected]
        DocumentRoot /var/www/html/example2/public

        <Directory /var/www/html/example2/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

             SSLEngine on

        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/example2.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/example2.com/privkey.pem
</VirtualHost>
4
  • You need to use the Apache installer for it, which will preconfigure everything. Try referring to certbot.eff.org/lets-encrypt/ubuntubionic-apache
    – Thomas Ward
    Commented Nov 13, 2019 at 15:45
  • I am got 'Congratulations! You have successfully enabled naturalobsessionnigeria.com (which is example2.com in my question)' after following the article. When I visited the page, it redirects to the contents on example1.com (in real life - www.70shops.com). Commented Nov 13, 2019 at 16:00
  • You cleared your browser cache before attempting to test this, yes? Browser caching usually is one of the main problems when debugging these things.
    – Thomas Ward
    Commented Nov 13, 2019 at 16:42
  • I am testing in incognito and it’s the same. See this, naturalobsessionnigeria.com redirects to the contents of 70shops.com. Kindly visit the urls and see if you can make any sense out of this problem Commented Nov 13, 2019 at 17:26

0

You must log in to answer this question.

Browse other questions tagged .