Re: httpd howto redirect port 80 to 443 in vm

2018-03-03 Thread niya

hi everyone


On 02/03/2018 18:45, contact - ulysse lab wrote:

Put into /etc/httpd.conf :

types { include "/usr/share/misc/mime.types" }

server "default" {

    listen on * tls port 443
    tls certificate "/etc/letsencrypt/live/example.com/fullchain.pem"
    tls key "/etc/letsencrypt/live/example.com/privkey.pem"

    root "/htdocs/example.com"

}

server "www.example.com" {

    alias "example.com"

    listen on * port 80
    block return 301 "https://$SERVER_NAME$REQUEST_URI;

}

Le 02/03/2018 à 15:51, Base Pr1me a écrit :

I simply have a block in my httpd.conf for my redirects:

server "example.com" {
 listen on $ext_if port 80
 alias "www.example.com"
 block return 301 "https://example.com/;
}

On Fri, Mar 2, 2018 at 7:40 AM, Solène Rapenne  wrote:


Le 2018-03-02 15:33, Matt M a écrit :


Why not use a .htaccess redirect?

https://www.sslshopper.com/apache-redirect-http-to-https.html


.htaccess file is a feature of Apache web server while we are
talking about httpd.





thanks for all the help
as i was just getting my feet wet with vmm
i hadn't setup a domainname in dns for the host
i was simply accessing the host machine via an ip address.
i modified the above example with the ip address of the host and 
redirection worked perfectly


my httpd.conf

# $OpenBSD: httpd.conf,v 1.17 2017/04/16 08:50:49 ajacoutot Exp $

#
# Macros
#
ext_addr="*"
#
# Global Options
#
# prefork 3
#
# Servers
#
# A minimal default server
server "default" {
    listen on $ext_addr tls port 443
    tls {
    key "/etc/ssl/private/server.key"
    certificate "/etc/ssl/server.crt"
    }
    directory {
    index "index.php"
    }
    location "*.php" {
    fastcgi socket "/run/php-fpm.sock"
    }
}

server "host server ip address" {
    listen on * port 80
    block return 301 "https://$SERVER_NAME$REQUEST_URI;
}

# Include MIME types instead of the built-in ones
types {
    include "/usr/share/misc/mime.types"
}

#---

shadrock



Re: httpd howto redirect port 80 to 443 in vm

2018-03-02 Thread contact - ulysse lab

Put into /etc/httpd.conf :

types { include "/usr/share/misc/mime.types" }

server "default" {

    listen on * tls port 443
    tls certificate "/etc/letsencrypt/live/example.com/fullchain.pem"
    tls key "/etc/letsencrypt/live/example.com/privkey.pem"

    root "/htdocs/example.com"

}

server "www.example.com" {

    alias "example.com"

    listen on * port 80
    block return 301 "https://$SERVER_NAME$REQUEST_URI;

}

Le 02/03/2018 à 15:51, Base Pr1me a écrit :

I simply have a block in my httpd.conf for my redirects:

server "example.com" {
 listen on $ext_if port 80
 alias "www.example.com"
 block return 301 "https://example.com/;
}

On Fri, Mar 2, 2018 at 7:40 AM, Solène Rapenne  wrote:


Le 2018-03-02 15:33, Matt M a écrit :


Why not use a .htaccess redirect?

https://www.sslshopper.com/apache-redirect-http-to-https.html


.htaccess file is a feature of Apache web server while we are
talking about httpd.






Re: httpd howto redirect port 80 to 443 in vm

2018-03-02 Thread michael
‎Don't test redirects with firefox not any other browser.
Use curl or any other tool so you can see exactly what happened (e.g. curl with 
-i to see the header)




  Originalnachricht  
Von: niya
Gesendet: Donnerstag, 1. März 2018 13:04
An: Solène Rapenne; obs...@high5.nl; misc@openbsd.org
Betreff: Re: httpd howto redirect port 80 to 443 in vm

Hi


On 27/02/2018 11:18, Solène Rapenne wrote:
> Le 2018-02-27 07:58, Mischa Peters a écrit :
>>> On 27 Feb 2018, at 05:04, niya <niyal...@gmail.com> wrote:
>>>
>>> hi
>>> using vmd in openbsd 6.2
>>> and following 
>>> http://thecyberrecce.net/2017/01/15/secure-webservers-with-openbsd-6-0-setting-up-httpd-mariadb-and-php/
>>> i have setup openbsd running a webserver
>>> everything installed and the webserver works via port 80 and 443.
>>> i can access the webserver from a remote client by browsing to the 
>>> ip of the host machine and redirecting to the vm address and port 
>>> using pf.
>>> i tried to setup port 80 redirection to port 443 so that all all 
>>> access is over HTTPS, when i use http://host ip, i am redirected to 
>>> https://default/
>>> how do i get the webserver to redirect to the ip address of the host 
>>> machine?
>>>
>>> my httpd.conf
>>>
>>> server "default" {
>>>     listen on $ext_addr port 80 block return 301 
>>> "https://$SERVER_NAME$REQUEST_URI;
>>> #   listen on $ext_addr port 80
>>>     listen on $ext_addr tls port 443
>>>     tls {
>>>     key "/etc/ssl/private/server.key"
>>>     certificate "/etc/ssl/server.crt"
>>>     }
>>>     directory {
>>>     index "index.php"
>>>     }
>>>     location "*.php" {
>>>     fastcgi socket "/run/php-fpm.sock"
>>>     }
>>>
>>>
>>> shadrock
>>
>> Hi,
>>
>> $SERVER_NAME uses the name you have specified at ‘server “default”’
>> which is “default” in this case.
>>
>> Mischa
>
> Exactly, $HTTP_HOST should be used instead of $SERVER_NAME for what
> you want to do.
>
thanks for the replies ,  i have tried your suggestion
the line in httpd.conf  now reads
 listen on $ext_addr port 80 block return 301 
"https://$HTTP_HOST$REQUEST_URI;
i now get the following in firefox

The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this 
address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept 
cookies.

shadrock



Re: httpd howto redirect port 80 to 443 in vm

2018-03-02 Thread Base Pr1me
Crap, naturally, don't forget "tls" in front of "port 443". Apologies.

On Fri, Mar 2, 2018 at 7:54 AM, Base Pr1me  wrote:

> I should mention for clarification there are two server sections. The
> second listens on 443 and does the tls and location heavy lifting.
> So, there are two:
>
> server "example.com" {
> listen on $ext_if port 80
> alias "www.example.com"
> block return 301 "https://example.com/;
> }
> server "example.com" {
> listen on $ext_if port 443
> alias "www.example.com"
>#rest of stuff
> }
>
> On Fri, Mar 2, 2018 at 7:51 AM, Base Pr1me  wrote:
>
>> I simply have a block in my httpd.conf for my redirects:
>>
>> server "example.com" {
>> listen on $ext_if port 80
>> alias "www.example.com"
>> block return 301 "https://example.com/;
>> }
>>
>> On Fri, Mar 2, 2018 at 7:40 AM, Solène Rapenne  wrote:
>>
>>> Le 2018-03-02 15:33, Matt M a écrit :
>>>
 Why not use a .htaccess redirect?

 https://www.sslshopper.com/apache-redirect-http-to-https.html

>>>
>>> .htaccess file is a feature of Apache web server while we are
>>> talking about httpd.
>>>
>>>
>>
>


Re: httpd howto redirect port 80 to 443 in vm

2018-03-02 Thread Base Pr1me
I should mention for clarification there are two server sections. The
second listens on 443 and does the tls and location heavy lifting.
So, there are two:

server "example.com" {
listen on $ext_if port 80
alias "www.example.com"
block return 301 "https://example.com/;
}
server "example.com" {
listen on $ext_if port 443
alias "www.example.com"
   #rest of stuff
}

On Fri, Mar 2, 2018 at 7:51 AM, Base Pr1me  wrote:

> I simply have a block in my httpd.conf for my redirects:
>
> server "example.com" {
> listen on $ext_if port 80
> alias "www.example.com"
> block return 301 "https://example.com/;
> }
>
> On Fri, Mar 2, 2018 at 7:40 AM, Solène Rapenne  wrote:
>
>> Le 2018-03-02 15:33, Matt M a écrit :
>>
>>> Why not use a .htaccess redirect?
>>>
>>> https://www.sslshopper.com/apache-redirect-http-to-https.html
>>>
>>
>> .htaccess file is a feature of Apache web server while we are
>> talking about httpd.
>>
>>
>


Re: httpd howto redirect port 80 to 443 in vm

2018-03-02 Thread Base Pr1me
I simply have a block in my httpd.conf for my redirects:

server "example.com" {
listen on $ext_if port 80
alias "www.example.com"
block return 301 "https://example.com/;
}

On Fri, Mar 2, 2018 at 7:40 AM, Solène Rapenne  wrote:

> Le 2018-03-02 15:33, Matt M a écrit :
>
>> Why not use a .htaccess redirect?
>>
>> https://www.sslshopper.com/apache-redirect-http-to-https.html
>>
>
> .htaccess file is a feature of Apache web server while we are
> talking about httpd.
>
>


Re: httpd howto redirect port 80 to 443 in vm

2018-03-02 Thread Solène Rapenne

Le 2018-03-02 15:33, Matt M a écrit :

Why not use a .htaccess redirect?

https://www.sslshopper.com/apache-redirect-http-to-https.html


.htaccess file is a feature of Apache web server while we are
talking about httpd.



Re: httpd howto redirect port 80 to 443 in vm

2018-03-02 Thread Matt M
Why not use a .htaccess redirect?

https://www.sslshopper.com/apache-redirect-http-to-https.html

On Thu, Mar 1, 2018 at 7:18 AM Bryan Harris  wrote:

> Alternate?: go back to original config and change
>
> server "default"
>
> to
>
> server "example.com"
>
> And maybe an alias for "www.example.com."
>
> Just a thought.
>
> V/r,
> Bryan
>
-- 
There's no place like 127.0.0.1


Re: httpd howto redirect port 80 to 443 in vm

2018-03-01 Thread Bryan Harris
Alternate?: go back to original config and change

server "default"

to

server "example.com"

And maybe an alias for "www.example.com."

Just a thought.

V/r,
Bryan


Re: httpd howto redirect port 80 to 443 in vm

2018-03-01 Thread niya

Hi


On 27/02/2018 11:18, Solène Rapenne wrote:

Le 2018-02-27 07:58, Mischa Peters a écrit :

On 27 Feb 2018, at 05:04, niya  wrote:

hi
using vmd in openbsd 6.2
and following 
http://thecyberrecce.net/2017/01/15/secure-webservers-with-openbsd-6-0-setting-up-httpd-mariadb-and-php/

i have setup openbsd running a webserver
everything installed and the webserver works via port 80 and 443.
i can access the webserver from a remote client by browsing to the 
ip of the host machine and redirecting to the vm address and port 
using pf.
i tried to setup port 80 redirection to port 443 so that all all 
access is over HTTPS, when i use http://host ip, i am redirected to 
https://default/
how do i get the webserver to redirect to the ip address of the host 
machine?


my httpd.conf

server "default" {
    listen on $ext_addr port 80 block return 301 
"https://$SERVER_NAME$REQUEST_URI;

#   listen on $ext_addr port 80
    listen on $ext_addr tls port 443
    tls {
    key "/etc/ssl/private/server.key"
    certificate "/etc/ssl/server.crt"
    }
    directory {
    index "index.php"
    }
    location "*.php" {
    fastcgi socket "/run/php-fpm.sock"
    }


shadrock


Hi,

$SERVER_NAME uses the name you have specified at ‘server “default”’
which is “default” in this case.

Mischa


Exactly, $HTTP_HOST should be used instead of $SERVER_NAME for what
you want to do.


thanks for the replies ,  i have tried your suggestion
the line in httpd.conf  now reads
 listen on $ext_addr port 80 block return 301 
"https://$HTTP_HOST$REQUEST_URI;

i now get the following in firefox

The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this 
address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept 
cookies.


shadrock



Re: httpd howto redirect port 80 to 443 in vm

2018-02-27 Thread Solène Rapenne

Le 2018-02-27 07:58, Mischa Peters a écrit :

On 27 Feb 2018, at 05:04, niya  wrote:

hi
using vmd in openbsd 6.2
and following 
http://thecyberrecce.net/2017/01/15/secure-webservers-with-openbsd-6-0-setting-up-httpd-mariadb-and-php/

i have setup openbsd running a webserver
everything installed and the webserver works via port 80 and 443.
i can access the webserver from a remote client by browsing to the ip 
of the host machine and redirecting to the vm address and port using 
pf.
i tried to setup port 80 redirection to port 443 so that all all 
access is over HTTPS, when i use http://host ip, i am redirected to 
https://default/
how do i get the webserver to redirect to the ip address of the host 
machine?


my httpd.conf

server "default" {
listen on $ext_addr port 80 block return 301 
"https://$SERVER_NAME$REQUEST_URI;

#   listen on $ext_addr port 80
listen on $ext_addr tls port 443
tls {
key "/etc/ssl/private/server.key"
certificate "/etc/ssl/server.crt"
}
directory {
index "index.php"
}
location "*.php" {
fastcgi socket "/run/php-fpm.sock"
}


shadrock


Hi,

$SERVER_NAME uses the name you have specified at ‘server “default”’
which is “default” in this case.

Mischa


Exactly, $HTTP_HOST should be used instead of $SERVER_NAME for what
you want to do.



Re: httpd howto redirect port 80 to 443 in vm

2018-02-27 Thread Mischa Peters

> On 27 Feb 2018, at 05:04, niya  wrote:
> 
> hi
> using vmd in openbsd 6.2
> and following 
> http://thecyberrecce.net/2017/01/15/secure-webservers-with-openbsd-6-0-setting-up-httpd-mariadb-and-php/
> i have setup openbsd running a webserver
> everything installed and the webserver works via port 80 and 443.
> i can access the webserver from a remote client by browsing to the ip of the 
> host machine and redirecting to the vm address and port using pf.
> i tried to setup port 80 redirection to port 443 so that all all access is 
> over HTTPS, when i use http://host ip, i am redirected to https://default/
> how do i get the webserver to redirect to the ip address of the host machine?
> 
> my httpd.conf
> 
> server "default" {
> listen on $ext_addr port 80 block return 301 
> "https://$SERVER_NAME$REQUEST_URI;
> #   listen on $ext_addr port 80
> listen on $ext_addr tls port 443
> tls {
> key "/etc/ssl/private/server.key"
> certificate "/etc/ssl/server.crt"
> }
> directory {
> index "index.php"
> }
> location "*.php" {
> fastcgi socket "/run/php-fpm.sock"
> }
> 
> 
> shadrock

Hi,

$SERVER_NAME uses the name you have specified at ‘server “default”’ which is 
“default” in this case. 

Mischa



httpd howto redirect port 80 to 443 in vm

2018-02-26 Thread niya

hi
using vmd in openbsd 6.2
and following 
http://thecyberrecce.net/2017/01/15/secure-webservers-with-openbsd-6-0-setting-up-httpd-mariadb-and-php/

i have setup openbsd running a webserver
everything installed and the webserver works via port 80 and 443.
i can access the webserver from a remote client by browsing to the ip of 
the host machine and redirecting to the vm address and port using pf.
i tried to setup port 80 redirection to port 443 so that all all access 
is over HTTPS, when i use http://host ip, i am redirected to 
https://default/
how do i get the webserver to redirect to the ip address of the host 
machine?


my httpd.conf

server "default" {
    listen on $ext_addr port 80 block return 301 
"https://$SERVER_NAME$REQUEST_URI;

#   listen on $ext_addr port 80
    listen on $ext_addr tls port 443
    tls {
    key "/etc/ssl/private/server.key"
    certificate "/etc/ssl/server.crt"
    }
    directory {
    index "index.php"
    }
    location "*.php" {
    fastcgi socket "/run/php-fpm.sock"
    }


shadrock