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: virtual host port forward to non https?
Author
davidstoll



Joined: 20 May 2024
Posts: 4

PostPosted: Mon 20 May '24 20:01    Post subject: virtual host port forward to non https? Reply with quote

I have it set so that if someone hits port 80 http://whatever.com, it forwards to https.

Recently, I added a new service on a new port. Is it possible to make it so that if someone hits another specific port (say port 1234), that it stays on http rather than going to https?

Here is the line I have within the <VirtualHost *:80> in my conf file:

Redirect / https://whatever.com

So, right now, if I try to go to http://whatever.com:1234, it forwards to https://whatever.com:1234, which doesn't work. Maybe the conf file line isn't doing this, so I guess I just need a little assistance tracking it down.
Back to top
Stray78



Joined: 15 Apr 2024
Posts: 18
Location: USA

PostPosted: Thu 23 May '24 12:30    Post subject: Reply with quote

Not sure how that is even possible. If your server is listening on port 80, it will not connect to mysite.com:1234. It should also not even redirect to https as it isnt listening on that port.

You would just need to add a vhost for that port...

<VirtualHost *:1234>
# Server Stuff #
ServerName mysite.com
DocumentRoot "D:/port-1234-site"

# Logging Stuff #
CustomLog "D:/logs/port-1234.log" "combined"

</VirtualHost>
Back to top
davidstoll



Joined: 20 May 2024
Posts: 4

PostPosted: Thu 23 May '24 19:29    Post subject: Reply with quote

My port 80 virtual host forwards to https. I have a 443 virtual host setup as well. Not that it matters too much, but I'm running on linux.

I tried to add a 1234 port virtual host section too, but it didn't seem to help.
Code:

<VirtualHost *:80>
    ServerName "mysite.com"
    ServerAlias *.mysite.com
    ServerAdmin webmaster@mysite.com
    DocumentRoot /data/mysite.com
    Redirect / https://mysite.com/
#randome aliases,etc........
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =*.mysite.com [OR]
    RewriteCond %{SERVER_NAME} =mysite.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    </VirtualHost>


<VirtualHost *:443>
    ServerName "mysite.com"
    ServerAlias *.mysite.com
    ServerAdmin webmaster@mysite.com
    DocumentRoot /data/mysite.com
#random aliases,etc........
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/mysite.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/mysite.com/privkey.pem
</VirtualHost>


It should even try to forward to https if I hit a different port, but it's almost like it's somehow getting to that redirect line from / to https. Maybe I should put the new virtual port section first or....?

Mod note: added code tags
Back to top
Stray78



Joined: 15 Apr 2024
Posts: 18
Location: USA

PostPosted: Fri 24 May '24 3:27    Post subject: Reply with quote

Yeah I get that. All my virtual hosts get a redirect permanent to https also.

If i go to my site... mysite.com:1234, mine doesnt forward to anything listening on port 80.

I get this.
Code:
The connection has timed out

An error occurred during a connection to mysite.com:1234.


In your httpd.conf do you have

Code:
Listen 1234 or Listen 192.0.2.5:1234


Obviously that would be your IP address.
Back to top
davidstoll



Joined: 20 May 2024
Posts: 4

PostPosted: Fri 24 May '24 14:19    Post subject: Reply with quote

The only thing in my httpd.conf is:

Servername blargblarg
DocumentRoot /home/webdocs


Just to make sure I didn't miss anything, I can get to the page, but I have to edit the url after it attempts to load, by removing the s.
Back to top
Stray78



Joined: 15 Apr 2024
Posts: 18
Location: USA

PostPosted: Sun 26 May '24 0:00    Post subject: Reply with quote

There should be a lot more in your config than two directives...

This is the listen directive...
https://httpd.apache.org/docs/2.4/mod/mpm_common.html#listen

And I just found this...
Code:
You only need to set the protocol if you are running on non-standard ports. For example, running an https site on port 8443:

Listen 192.170.2.1:8443 https


So maybe you need this...
Listen 192.170.2.1:1234 http (Replace with your listening IP)
Back to top
davidstoll



Joined: 20 May 2024
Posts: 4

PostPosted: Wed 29 May '24 14:47    Post subject: Reply with quote

Unfortunately adding a listen line didn't help.

I used 127.0.0.1 as well as my public ip, restarted appache each time, but no joy. Sad
Back to top


Reply to topic   Topic: virtual host port forward to non https? View previous topic :: View next topic
Post new topic   Forum Index -> Apache