0

I have been reading around and trying different configurations to get a request to my server on port 10000 to redirect a http to a https request.

For some reason I can't figure out how to make it happen when i use port 10000 although i can set a rewrite rule for port 80 (implicit) to do it:

All I want is a request as follows:

http://example.com:10000

to redirect me to

https://example.com:10000

My current, vhost, the last of many different attempts is currently set as follows, but it doesn't seem to work at all:

<VirtualHost *:10000>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_POST}%{REQUEST_URI}

ErrorLog "/var/log/httpd/webmin-redirect_error_log.log"
CustomLog "/var/log/httpd/webmin-redirect_access_log.log" common
</VirtualHost>

I'v also tried a few other things but nothing seems to work, any help would be appreciated.

EDIT: I already have a re-write in my httpd.conf that redirects port 80 to https. If I access port 10000 externally it is redirected to https, but from the lan "http://192.168.0.2:10000" it doesnt.

2
  • 2
    Are you trying to redirect requests to Webmin? If I remember correctly, webmin has it's own web server and doesn't use Apache. So inside the LAN, you might be hitting webmin's server and the request never gets to Apache. – Marie Fischer Nov 12 '11 at 15:32
  • Indeed I am trying to do it with webmin, that would make sense, I'll poke around, thanks. – Hamid Nov 12 '11 at 15:34
1

You have to decide whether port 10000 is HTTP or HTTPS. For HTTPS you will have to create a virtualhost of it's own with SSL* configuration lines. You cannot have both in the same IP in the same port.

0

You can easily do it in:

  • Webmin > Config Webmin > SSl Config

  • Check yes in > Redirect non-SSL requests to SSL mode?

  • Reload browser and clear cache (Ctrl + Shift +R)

-1

This can be archived by redirecting to a custom "400 - Bad Request" page and modify the redirection with a rewrite rule. In the following example i request

http://test.mydomain.com:27000

and get redirected to

https://test.mydomain.com:27000

with one virtual host.

Code:

ErrorDocument 400 /

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^/?(.*) https://%{SERVER_NAME}:27000/$1 [R,L]

Or you simply redirect directly to the HTTPS version of the page.

Code:

 ErrorDocument 400 https://test.mydomain.com:27000

But you will loose the ability to redirect on a real "Bad Request" page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.