Problem to redirect from https to http

Issues related to configuring your network
Post Reply
JohnReese
Posts: 10
Joined: 2021/02/27 16:39:04

Problem to redirect from https to http

Post by JohnReese » 2021/03/14 22:55:14

Hi, i have already setup my firewall:

Code: Select all

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eno1
  sources:
  services: dhcpv6-client ftp http https ssh
  ports: 80/tcp 443/tcp 21/tcp 20-21/tcp 30000-31000/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
and setup my .htaccess

Code: Select all

RewriteCond %{HTTPS} on
RewriteRule ^/?$ http://%{SERVER_NAME}/ [R=301]
RewriteRule ^inner/directory/?$ http://%{SERVER_NAME}/inner/directory/ [R=301,L]
I have also tried this:

Code: Select all

RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
but it still doesn't work. When i try to access to https it said me err_connection_refused
How can i fix it? Thanks
I want that when a user try to access to https it will redirect to http.

Whoever
Posts: 1357
Joined: 2013/09/06 03:12:10

Re: Problem to redirect from https to http

Post by Whoever » 2021/03/14 23:10:09

Why do you want to rewrite to http? Are you trying to set up a reverse proxy?

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Problem to redirect from https to http

Post by TrevorH » 2021/03/15 01:56:00

Also from your firewall output, you have opened both services and ports for http(80) and https(443) and you should remove the port version. Using --add-service=http and --add-service=https is correct and sufficient, there is no need to open the numeric ports as well.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

JohnReese
Posts: 10
Joined: 2021/02/27 16:39:04

Re: Problem to redirect from https to http

Post by JohnReese » 2021/03/15 08:22:03

Whoever wrote:
2021/03/14 23:10:09
Why do you want to rewrite to http? Are you trying to set up a reverse proxy?
Because if i try to access my site with https:// it doesn't work. It said error and do not redirect to http://

JohnReese
Posts: 10
Joined: 2021/02/27 16:39:04

Re: Problem to redirect from https to http

Post by JohnReese » 2021/03/15 08:22:23

TrevorH wrote:
2021/03/15 01:56:00
Also from your firewall output, you have opened both services and ports for http(80) and https(443) and you should remove the port version. Using --add-service=http and --add-service=https is correct and sufficient, there is no need to open the numeric ports as well.
So, if i disable numeric port it will work and redirect to http?

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Problem to redirect from https to http

Post by jlehtone » 2021/03/15 09:11:57

JohnReese wrote:
2021/03/15 08:22:23
So, if i disable numeric port it will work and redirect to http?
No. That just reduces redundant config.
JohnReese wrote:
2021/03/15 08:22:03
Because if i try to access my site with https:// it doesn't work.
Obvious questions are:
* Why it does not work?
* Is the security necessary?

It is much more common to have a https site and provide http->https redirect as convenience for users.

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Problem to redirect from https to http

Post by TrevorH » 2021/03/15 09:31:09

If you enter https://your.site/ in your browser then it will attempt to make an https connection to port 443 on your server. Your server is then set up to redirect that silently to plain text http on port 80. Your browser is going to get very confused by trying to speak SSL to a non-SSL port.

What are you really trying to do and why?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Whoever
Posts: 1357
Joined: 2013/09/06 03:12:10

Re: Problem to redirect from https to http

Post by Whoever » 2021/03/16 04:09:59

JohnReese wrote:
2021/03/15 08:22:03


Because if i try to access my site with https:// it doesn't work.
Work on that problem, get out of the blind alley (redirection) that you are currently in.

When you try to access the https:// site, what's in the logs? Make sure you look at all the log files.

Post Reply