You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by MEjaz <me...@cyberia.net.sa> on 2020/08/11 07:00:35 UTC
[users@httpd] http-https
Hello,.
I have requirement to redirect the url. Whoever typed my site
http://newtraffic.cyberia.net.sa , it should redirect to
https://newtraffic.cyberia.net.sa
I am bit struggling to achieve this. please assit
Ejaz
Re: [users@httpd] http-https
Posted by Jim Albert <ji...@netrition.com>.
On 8/11/2020 10:44 AM, Nick Kew wrote:
>
>> On 11 Aug 2020, at 08:52, MEjaz <me...@cyberia.net.sa> wrote:
>>
>> Bad Request
>> Your browser sent a request that this server could not understand.
>> Reason: You're speaking plain HTTP to an SSL-enabled server port.
>> Instead use the HTTPS scheme to access this URL, please.
> Read the error message and log. It's giving you exactly the advice you need.
> My guess is that you've configured SSL on both ports.
>
> More generally, don't confuse the configuration of your http and https vhosts.
> If you have the redirect in the latter, it becomes an infinite loop!
>
> (the mod_rewrite advice is wrong on too many levels to enumerate).
>
Many ways of handling http->https, mod_rewrite being one of them with
variations of the syntax based on what you want to do.
Positive guidance per stack overflow.
https://stackoverflow.com/questions/10489895/http-to-https-through-htaccess
(agreed... likely some other apache config issues for OP involving port
configs).
Jim
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] http-https
Posted by Nick Kew <ni...@apache.org>.
> On 11 Aug 2020, at 08:52, MEjaz <me...@cyberia.net.sa> wrote:
>
> Bad Request
> Your browser sent a request that this server could not understand.
> Reason: You're speaking plain HTTP to an SSL-enabled server port.
> Instead use the HTTPS scheme to access this URL, please.
Read the error message and log. It's giving you exactly the advice you need.
My guess is that you've configured SSL on both ports.
More generally, don't confuse the configuration of your http and https vhosts.
If you have the redirect in the latter, it becomes an infinite loop!
(the mod_rewrite advice is wrong on too many levels to enumerate).
--
Nick Kew
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] http-https
Posted by MEjaz <me...@cyberia.net.sa>.
Thanks you so much for your email.
Here Is my httpd.conf inorder to achieve whoever type
http://newtraffic.cyberia.net.sa then it should redirect https://newtraffic.
cyberia.net.sa
=============================================
<VirtualHost *:80>
DocumentRoot /usr/share/cacti
ServerName newtraffic.cyberia.net.sa
# RedirectMatch "^/$" "https://newtraffic.cyberia.net.sa/cacti/"
Redirect permanent "/" "https://newtraffic.cyberia.net.sa/"
ErrorLog /var/log/httpd/error_log
</VirtualHost>
===================================================
When I tried to check from browser, I got the below. where as my apache is
listening on both ports 80 and 443. Please assist.
==================================================
Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.
=============================================================
===============
[root@nc rra]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor
preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Tue 2020-08-11 10:39:10 +03; 4s ago
Docs: man:httpd.service(8)
Main PID: 285583 (httpd)
Status: "Started, listening on: port 443, port 80"
Tasks: 213 (limit: 307056)
Memory: 46.3M
CGroup: /system.slice/httpd.service
├─285583 /usr/sbin/httpd -DFOREGROUND
├─285584 /usr/sbin/httpd -DFOREGROUND
├─285585 /usr/sbin/httpd -DFOREGROUND
├─285586 /usr/sbin/httpd -DFOREGROUND
└─285587 /usr/sbin/httpd -DFOREGROUND
Aug 11 10:39:10 nc.cyberia.net.sa systemd[1]: Starting The Apache HTTP
Server...
Aug 11 10:39:10 nc.cyberia.net.sa systemd[1]: Started The Apache HTTP
Server.
Aug 11 10:39:10 nc.cyberia.net.sa httpd[285583]: Server configured,
listening on: port 443, port 80
[root@nc rra]# vi /etc/httpd/conf/httpd.conf
-----Original Message-----
From: Freek de Kruijf [mailto:f.de.kruijf@gmail.com]
Sent: Tuesday, August 11, 2020 10:25 AM
To: users@httpd.apache.org
Subject: Re: [users@httpd] http-https
Op dinsdag 11 augustus 2020 09:00:35 CEST schreef MEjaz:
> Hello,.
>
>
>
> I have requirement to redirect the url. Whoever typed my site
> http://newtraffic.cyberia.net.sa , it should redirect to
> https://newtraffic.cyberia.net.sa
>
>
>
> I am bit struggling to achieve this. please assit
>
>
>
> Ejaz
You can do this with a directive in the .conf file for
http://newtraffic.cyberia.net.sa :
Redirect permanent "/" "https://newtraffic.cyberia.net.sa/"
--
fr.gr.
Freek de Kruijf
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] http-https
Posted by Freek de Kruijf <f....@gmail.com>.
Op dinsdag 11 augustus 2020 09:00:35 CEST schreef MEjaz:
> Hello,.
>
>
>
> I have requirement to redirect the url. Whoever typed my site
> http://newtraffic.cyberia.net.sa , it should redirect to
> https://newtraffic.cyberia.net.sa
>
>
>
> I am bit struggling to achieve this. please assit
>
>
>
> Ejaz
You can do this with a directive in the .conf file for
http://newtraffic.cyberia.net.sa :
Redirect permanent "/" "https://newtraffic.cyberia.net.sa/"
--
fr.gr.
Freek de Kruijf
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] http-https [EXT]
Posted by James Smith <js...@sanger.ac.uk>.
Add also remember to add the HSTS headers
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
{only put includeSubDomains & preload if you can} this stops the client sending further HTTP requests but only HTTPS {most web servers}
This can stop the plain text password issue...
From: Jim Albert <ji...@netrition.com>
Sent: 11 August 2020 15:07
To: users@httpd.apache.org
Subject: Re: [users@httpd] http-https [EXT]
On 8/11/2020 3:00 AM, MEjaz wrote:
Hello,.
I have requirement to redirect the url. Whoever typed my site http://newtraffic.cyberia.net.sa [newtraffic.cyberia.net.sa]<https://urldefense.proofpoint.com/v2/url?u=http-3A__newtraffic.cyberia.net.sa&d=DwMD-g&c=D7ByGjS34AllFgecYw0iC6Zq7qlm8uclZFI0SqQnqBo&r=oH2yp0ge1ecj4oDX0XM7vQ&m=u_JqEjDWgo-OocL30p2adrqMP2ANeNzVGM00nEb2SGw&s=pwH-t5l78trs4NhuTkbW_6At5rheFwUfObRpuI3RYjI&e=> , it should redirect to https://newtraffic.cyberia.net.sa [newtraffic.cyberia.net.sa]<https://urldefense.proofpoint.com/v2/url?u=https-3A__newtraffic.cyberia.net.sa&d=DwMD-g&c=D7ByGjS34AllFgecYw0iC6Zq7qlm8uclZFI0SqQnqBo&r=oH2yp0ge1ecj4oDX0XM7vQ&m=u_JqEjDWgo-OocL30p2adrqMP2ANeNzVGM00nEb2SGw&s=KphJ7NJgAkY4K77U__kmooopvQ8L0ZTP6kNRWE06UXM&e=>
I am bit struggling to achieve this. please assit
Ejaz
As long as the request is staying on the same server, mod_rewrite is a good use for this and I believe avoids another request as in a redirect.
The following 3 lines would go in your httpd.conf file.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) MailScanner has detected a possible fraud attempt from "%" claiming to be https://% [%]<https://urldefense.proofpoint.com/v2/url?u=https-3A__-25&d=DwMD-g&c=D7ByGjS34AllFgecYw0iC6Zq7qlm8uclZFI0SqQnqBo&r=oH2yp0ge1ecj4oDX0XM7vQ&m=u_JqEjDWgo-OocL30p2adrqMP2ANeNzVGM00nEb2SGw&s=JHn6HqEcexneHcW_Odljb9BQOM1USP7CjXGEHkEtitc&e=>{SERVER_NAME}$1 [L,R=302]
https://httpd.apache.org/docs/current/mod/mod_rewrite.html [httpd.apache.org]<https://urldefense.proofpoint.com/v2/url?u=https-3A__httpd.apache.org_docs_current_mod_mod-5Frewrite.html&d=DwMD-g&c=D7ByGjS34AllFgecYw0iC6Zq7qlm8uclZFI0SqQnqBo&r=oH2yp0ge1ecj4oDX0XM7vQ&m=u_JqEjDWgo-OocL30p2adrqMP2ANeNzVGM00nEb2SGw&s=9KhRrRpZ6Rb0u_hYOPYk05kX7QhDnWdXStTv2j3hDiA&e=>
This assumes you want all http traffic handled via https and not just the root of your site.
Change the 302 (temporary) to 301 (permanent) once you know things are working as you like.
Jim
--
The Wellcome Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.
Re: [users@httpd] http-https
Posted by Jim Albert <ji...@netrition.com>.
On 8/11/2020 3:00 AM, MEjaz wrote:
>
> Hello,.
>
> I have requirement to redirect the url. Whoever typed my site
> http://newtraffic.cyberia.net.sa , it should redirect to
> https://newtraffic.cyberia.net.sa
>
> I am bit struggling to achieve this. please assit
>
> Ejaz
>
As long as the request is staying on the same server, mod_rewrite is a
good use for this and I believe avoids another request as in a redirect.
The following 3 lines would go in your httpd.conf file.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}$1 [L,R=302]
https://httpd.apache.org/docs/current/mod/mod_rewrite.html
This assumes you want all http traffic handled via https and not just
the root of your site.
Change the 302 (temporary) to 301 (permanent) once you know things are
working as you like.
Jim