Julian Bermolen
Julian Bermolen

Reputation: 25

How configure multiples process on 443 port? Apache - ubuntu

here its my problem:

I have 2 applications configured on a server. React (client) and nodejs backend with their respective domains. 1 - example1.com 2 - example2.com

I have configured both SSL certificates for each of it as well. The problem occurs when you want to start the backend on the same port that the client is running.

Is it possible to run 2 processes on it? How should I do it?

these are my virtual host files:

example1-le.ssl.conf


<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName example1.com
    ServerAlias www.example1.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/example1
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


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

example1.conf

        ServerName example1.com
        ServerAlias example1.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/example/build

        <Directory "/var/www/example/build">
          RewriteEngine on
         # Don't rewrite files or directories
          RewriteCond %{REQUEST_FILENAME} -f [OR]
          RewriteCond %{REQUEST_FILENAME} -d
          RewriteRule ^ - [L]
           # Rewrite everything else to index.html to allow html5 state links
           RewriteRule ^ index.html [L]
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteCond %{SERVER_NAME} =example1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

And the same for the another one.

When i tried to start the second project i receive : EADDRINUSE: address already in use :::443

Thanks a lot for you help

Upvotes: 0

Views: 110

Answers (1)

Inc0
Inc0

Reputation: 809

You can NOT have to 2 different processes bind on the same port. What Olaf Kock suggested works fine and is easy to implement: you install apache on a dedicated server (or on the same machine: there's no difference) and then you configure a reverse proxy (the module is called mod_proxy). There are also other solutions (like haproxy) which require a bit more complex configuration but provide many more configuration options.

Upvotes: 1

Related Questions