Monday, February 26, 2018

Re: httpd howto redirect port 80 to 443 in vm

> On 27 Feb 2018, at 05:04, niya <niyalevi@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

No comments:

Post a Comment