logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Single Domain servicing multipule ports on a single host.
Author
myalias



Joined: 26 Jul 2021
Posts: 2
Location: new zealand

PostPosted: Wed 28 Jul '21 12:26    Post subject: Single Domain servicing multipule ports on a single host. Reply with quote

Kia Ora Tatou.
James from New Zealand calling.....

Before I start uploading a mess of configs and convoluted reasons why I haven got this to work yet I will try and ask a simple question.

Q: Is it possible to have a single domain redirect/forward to an internal address:port.

Example 1:
www.example.com/media1 is serviced by www.internal.int:8081

and

www.example.com/media2 is serviced by www.internal.int:8082


I do have a working reverse proxy with valid LetEncrypt SSL cert that I could publish tomorrow.
it currently forwards/redirects www.example.com to www.internal.int:8081

Nga Mihi.
Thanks you very much for you king donation.
Thank you very much thank you very very very much...

James.
Back to top
mraddi



Joined: 27 Jun 2016
Posts: 152
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Wed 28 Jul '21 14:40    Post subject: Reply with quote

Hello James,

A: yes, this is possible.

Ports used on the internal and external ressources do not need to match. Its only config on the reverse-proxy/loadbalancer to do the matching.

I don't know if it is useful/practical to use non-standard-ports on the external, but it is possible Smile
Back to top
myalias



Joined: 26 Jul 2021
Posts: 2
Location: new zealand

PostPosted: Thu 29 Jul '21 3:16    Post subject: Reply with quote

Great, so i'm not trying to reinvent the wheel.
I have searched this problem at length but as yet haven't found an example that I can re-engineer.
This is likely as I don't know the terminologies and little to nothing about the Acache language.

Could someone just give me the answer to the coding I need to apply to my .conf.

An example of the code required to get....
www.example.com/site1 redirects/forwards to www.internal.int:8088

and

www.example.com/site2 redirects/forwards to www.internal.int:9088

I can then recode using my URLS and test.

I have tried to keep the enviroment simple, default apache2.conf and 000-default.conf... etc
I have enabled Apache2Proxy.conf to manage the Reverse Proxy... sell below.



Code:

<VirtualHost *:80>
    ServerName myalias.example.com

    # Uncomment for HTTP to HTTPS redirect
    Redirect permanent / https://myalias.example.com

    ErrorLog /var/log/apache2/myalias.example.com-error.log
    CustomLog /var/log/apache2/myalias.example.com-access.log combined
</VirtualHost>

# Uncomment this section after you have acquired a SSL Certificate
# If you are not using a SSL certificate, replace the 'redirect'
# line above with all lines below starting with 'Proxy'
<IfModule mod_ssl.c>
   <VirtualHost *:443>
        ServerName myalias.example.com

        ProxyPreserveHost On

        ProxyPass "/socket" "ws://myalias.example.com:8081/socket"
        ProxyPassReverse "/socket" "ws://myalias.example.com:8081/socket"

        ProxyPass "/" "http://myalias.example.com:8081/"
        ProxyPassReverse "/" "http://myalias.example.com:8081/"

        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/myalias.example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/myalias.example.com/privkey.pem
        Protocols h2 http/1.1

        ErrorLog /var/log/apache2/myalias.example.com-error.log
        CustomLog /var/log/apache2/myalias.example.com-access.log combined
   </VirtualHost>
</IfModule>
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Fri 30 Jul '21 10:02    Post subject: Reply with quote

Code:

<VirtualHost *:443>
    ServerName myalias.example.com
    DocumentRoot /home/example/htdocs
    ErrorDocument 503 /500.html
    <Directory /home/example/htdocs>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    SSLProxyEngine on
    ProxyRequests off
    ProxyPreserveHost On

    <Location "/site1">
        ProxyPass /500.html !
        ProxyPass /site1 http://127.0.0.1:8081/ nocanon
        ProxyPassReverse /site1 http://127.0.0.1:8081/

        RewriteEngine on
        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteCond %{HTTP:Connection} upgrade [NC]
        RewriteRule ^/site1?(.*) "ws://127.0.0.1:8081/$1" [P,L]
    </Location>

    <Location "/site2">
        ProxyPass /500.html !
        ProxyPass /site2 http://127.0.0.1:9088/ nocanon
        ProxyPassReverse /site2 http://127.0.0.1:9088/

        RewriteEngine on
        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteCond %{HTTP:Connection} upgrade [NC]
        RewriteRule ^/site2?(.*) "ws://127.0.0.1:9088/$1" [P,L]
    </Location>

    RequestHeader set X-Forwarded-Proto https
    RequestHeader set X-Forwarded-Port 443

    Header always unset Content-Security-Policy

    ErrorLog /var/logs/apache2/myalias.example.com.error.log
    TransferLog /var/logs/apache2/myalias.example.com.access.log

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/myalias.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/myalias.example.com/privkey.pem
</VirtualHost>


it might be easier to use different sub domains.

Code:

<VirtualHost *:443>
    ServerName myalias.example.com
    DocumentRoot /home/example/htdocs
    ErrorDocument 503 /500.html
    <Directory /home/example/htdocs>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    SSLProxyEngine on
    ProxyRequests off
    ProxyPreserveHost On

   
    ProxyPass /500.html !
    ProxyPass / http://127.0.0.1:8081/ nocanon
    ProxyPassReverse / http://127.0.0.1:8081/

    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule ^/?(.*) "ws://127.0.0.1:8081/$1" [P,L]

    RequestHeader set X-Forwarded-Proto https
    RequestHeader set X-Forwarded-Port 443

    Header always unset Content-Security-Policy

    ErrorLog /var/logs/apache2/myalias.example.com.error.log
    TransferLog /var/logs/apache2/myalias.example.com.access.log

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/myalias.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/myalias.example.com/privkey.pem
</VirtualHost>

<VirtualHost *:443>
    ServerName myalias2.example.com
    DocumentRoot /home/example/htdocs
    ErrorDocument 503 /500.html
    <Directory /home/example/htdocs>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    SSLProxyEngine on
    ProxyRequests off
    ProxyPreserveHost On

   
    ProxyPass /500.html !
    ProxyPass / http://127.0.0.1:9088/ nocanon
    ProxyPassReverse / http://127.0.0.1:9088/

    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule ^/?(.*) "ws://127.0.0.1:9088/$1" [P,L]

    RequestHeader set X-Forwarded-Proto https
    RequestHeader set X-Forwarded-Port 443

    Header always unset Content-Security-Policy

    ErrorLog /var/logs/apache2/myalias2.example.com.error.log
    TransferLog /var/logs/apache2/myalias2.example.com.access.log

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/myalias2.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/myalias2.example.com/privkey.pem
</VirtualHost>
Back to top
chamroeun



Joined: 02 Nov 2021
Posts: 2
Location: cambodia

PostPosted: Wed 03 Nov '21 7:04    Post subject: ProxyWebsocketIdleTimeout not working Reply with quote

Hi,
I already upgrade my apache to 2.4.5 but still ProxyWebsocketIdleTimeout is not available.

Any suggestion?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 04 Nov '21 0:06    Post subject: Re: ProxyWebsocketIdleTimeout not working Reply with quote

chamroeun wrote:
Hi,
I already upgrade my apache to 2.4.5 but still ProxyWebsocketIdleTimeout is not available.

Any suggestion?


If I remember correctly that is only available in trunk.

See https://github.com/apache/httpd/commit/4b5394837f82c9c3bb8bdd1191520b6cb55debd6#diff-6e833b90e7c1c4aee226e000b933193de42e16c79ceb3bafa85bb1324fc5545a
Back to top


Reply to topic   Topic: Single Domain servicing multipule ports on a single host. View previous topic :: View next topic
Post new topic   Forum Index -> Apache