0

I have a server running on Linode that has 3 subdomains. Every subdomain is a diferent Angular 8 Application and have it´s own backend.

xyz.example.com

  • xyz.example.com:8080

abc.example.com

  • abc.example.com:8081

pqr.example.com

  • pqr.example.com:8082

The three of them were working just fine, but, It was on http and the "Insecure connection" icon was there all the time.

I installed a SSL certificate using "certbot --apache". The front end is fine, but, it doesn´t comunicate to back end anymore.

I keep getting the "net::ERR_SSL_PROTOCOL_ERROR" error.

Doing some search I think configuring apache to run as a reverse proxy could help (not sure though).

Here is my xyz.example.com.conf

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName app.nordy.com.br
ServerAlias www.app.nordy.com.br
DocumentRoot /var/www/html/app.nordy.com.br/dist
<Directory /var/www/html/app.nordy.com.br/dist>
    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} =www.app.nordy.com.br [OR]
RewriteCond %{SERVER_NAME} =app.nordy.com.br
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

And here is my default-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

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

    SSLEngine on
    SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
    </Directory>

 </VirtualHost>
 </IfModule>

Can someone tell what to do or point me to the right direction? What do I do to make things work again? Thank you.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47

1 Answers1

0

Your http virtual host just redirects to https. Yes? You can do that very simply with

<VirtualHost *:80>
  ServerName abc.example.com
  ServerAlias www.abc.example.com
  Redirect permanent / https://abc.example.com/
</VirtualHost>

Now in your https virtual host, you need to proxy connections to the back end. Something like

<VirtualHost *:443>
  ServerName abc.example.com
  ServerAlias www.abc.example.com
  SSLEngine on
  ProxyPass        / http://abc.example.com:8081
  ProxyPassReverse / http://abc.example.com:8081
</VirtualHost>

See ProxyPass and ProxyPassReverse.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47