DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 12th April 2018
toprank toprank is offline
Fdisk Soldier
 
Join Date: Feb 2018
Posts: 54
Default httpd's equivalent of Apache's Alias

What's the equivalent in httpd for Apache's Alias directive?

For example, assuming I have an application at /var/www/theAppWeWant and I want to access it from domain.tld/thatapp, and the server root for domain.tld is the default /var/www/htdocs, how is it done?

Apache, for example, would simply be:

Code:
Alias /thatapp /var/www/theAppWeWant
This httpd.conf, however, isn't getting the job done:

Code:
server "domain.tld" {
        alias www.domain.tld
        listen on * port 80
        listen on * tls port 443
        directory index index.php
        
        tls {
                key "/etc/ssl/private/domain.tld.key"
                certificate "/etc/ssl/domain.tld.fullchain.pem"
        }

        location "^/thatapp/*" {
                root "/theAppWeWant"
                directory index index.php
                fastcgi socket "/run/php-fpm.sock"
        }

        location "/*.php*" {
                fastcgi socket "/run/php-fpm.sock"
        }
}
Reply With Quote
  #2   (View Single Post)  
Old 12th April 2018
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

Try without the caret character.
Reply With Quote
  #3   (View Single Post)  
Old 13th April 2018
toprank toprank is offline
Fdisk Soldier
 
Join Date: Feb 2018
Posts: 54
Default

Thanks, jggimi, but that didn't work either. It's as though httpd is completely ignoring the whole location "/thatapp/*" directive because if I copy /var/www/theAppWeWant to /var/www/htdocs/theAppWeWant, it is reachable with domain.tld/theAppWeWant/index.php but not domain.tld/thatapp requests; the latter return a 404 Not found (in the ironic comic sans on my MacBook lol!).

Code:
domain.tld 123.456.789 - - [13/Apr/2018:11:52:31 +1000] "GET / HTTP/1.1" 200 0
domain.tld 123.456.789 - - [13/Apr/2018:11:52:38 +1000] "GET / HTTP/1.1" 200 0
domain.tld 123.456.789 - - [13/Apr/2018:11:52:39 +1000] "GET /theAppWeWant/index.php HTTP/1.1" 200 0
domain.tld 123.456.789 - - [13/Apr/2018:11:52:39 +1000] "GET /thatapp HTTP/1.1" 404 0
domain.tld 123.456.789 - - [13/Apr/2018:11:52:41 +1000] "GET /thatapp HTTP/1.1" 404 0
domain.tld 123.456.789 - - [13/Apr/2018:11:52:46 +1000] "GET /theAppWeWant/index.php HTTP/1.1" 200 0
domain.tld 123.456.789 - - [13/Apr/2018:11:52:47 +1000] "GET /theAppWeWant/index.php HTTP/1.1" 200 0
domain.tld 123.456.789 - - [13/Apr/2018:11:54:28 +1000] "GET / HTTP/1.1" 200 0
domain.tld 123.456.789 - - [13/Apr/2018:11:54:29 +1000] "GET /theAppWeWant/index.php HTTP/1.1" 200 0
domain.tld 123.456.789 - - [13/Apr/2018:11:54:29 +1000] "GET /thatapp HTTP/1.1" 404 0
Code:
server "domain.tld" {
        alias www.domain.tld
        listen on * port 80
        listen on * tls port 443
        directory index index.php
        
        tls {
                key "/etc/ssl/private/domain.tld.key"
                certificate "/etc/ssl/domain.tld.fullchain.pem"
        }

        location "/thatapp/*" {
                root "/theAppWeWant"
                directory index index.php
                fastcgi socket "/run/php-fpm.sock"
        }

        location "/*.php*" {
                fastcgi socket "/run/php-fpm.sock"
        }
}
Reply With Quote
  #4   (View Single Post)  
Old 13th April 2018
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

I use location{} with acme-client(1) on one of my systems, where it works fine.
Code:
server "jggimi.net" {
        alias "www.jggimi.net"
        listen on * port www
        listen on :: port www
        block return 301 "https://$SERVER_NAME$REQUEST_URI"
}

server "jggimi.net" {
        alias "www.jggimi.net"
        listen on * tls port https
        listen on :: tls port https
        hsts
        tls certificate "/etc/ssl/acme/fullchain.pem"
        tls key "/etc/ssl/acme/private/privkey.pem"
        tls ocsp "/etc/ssl/acme/cert.der"
        location "/.well-known/acme-challenge/*" {
                root "/acme"
                root strip 2
           }
}
However, my webserver that uses php_fpm runs nginx instead of httpd(), because I require client certificates.
Reply With Quote
  #5   (View Single Post)  
Old 13th April 2018
toprank toprank is offline
Fdisk Soldier
 
Join Date: Feb 2018
Posts: 54
Default

Yeah, acme works for me, too, on the same box; same server. But this location isn't being parsed at all for some reason.
Reply With Quote
  #6   (View Single Post)  
Old 13th April 2018
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

You may want to take this to the misc@ mailing list, where there is a much larger community of httpd() users.
Reply With Quote
  #7   (View Single Post)  
Old 13th April 2018
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

Hrmm.. I just thought of something - perhaps you need to root strip? We use root strip 2 with acme-client. Does root strip 1 work?
Reply With Quote
  #8   (View Single Post)  
Old 14th April 2018
toprank toprank is offline
Fdisk Soldier
 
Join Date: Feb 2018
Posts: 54
Default

Okay, we’re making some progress. With root strip 1, the correct location of /var/www/theAppWeWant/index.php is served to domain.tld/thatapp/index.php requests. However, domain.tld/thatapp returns a 404 not found.

Code:
server "domain.tld" {
        alias www.domain.tld
        listen on * port 80
        listen on * tls port 443
        root “/domain”
        directory index index.php

        tls {
                key "/etc/ssl/private/domain.tld.key"
                certificate "/etc/ssl/domain.tld.fullchain.pem"
        }

        connection max request body 10000000000

        location "/thatapp/*" {
                directory index index.php
                root "/theAppWeWant"
                root strip 1
                fastcgi socket "/run/php-fpm.sock"
        }

        location "/*.php*" {
                fastcgi socket "/run/php-fpm.sock"
        }

        location "/.well-known/acme-challenge/*" {
                root "/acme"
                root strip 2
        }
}

server "cloud.domain.tld" {
        listen on * tls port 443
        root "/nextcloud/"
        directory index index.php
        tls {
                key "/etc/ssl/private/domain.tld.key"
                certificate "/etc/ssl/domain.tld.fullchain.pem"
        }
        hsts
        connection max request body 10000000000

        location "/db_structure.xml" { block }
        location "/.ht*"             { block }
        location "/README"           { block }
        location "/data*"            { block }
        location "/config*"          { block }

        location "/*.php*" {
                fastcgi socket "/run/php-fpm.sock"
        }
}

Code:
# tail -f /var/www/logs/access.log
domain.tld 123.456.789 - - [14/Apr/2018:09:55:19 +1000] "GET /itdelta HTTP/1.1" 404 0
domain.tld 123.456.789 - - [14/Apr/2018:09:55:25 +1000] "GET /itdelta HTTP/1.1" 404 0
domain.tld 123.456.789 - - [14/Apr/2018:09:56:07 +1000] "GET /itdelta/index.php HTTP/1.1" 200 0
domain.tld 123.456.789 - - [14/Apr/2018:09:56:35 +1000] "GET /itdelta HTTP/1.1" 404 0
domain.tld 123.456.789 - - [14/Apr/2018:09:56:36 +1000] "GET /itdelta HTTP/1.1" 404 0
domain.tld 66.249.69.129 - - [14/Apr/2018:09:57:04 +1000] "<UNKNOWN> " 408 0
cloud.domain.tld 123.456.789 - - [14/Apr/2018:10:00:02 +1000] "GET /cron.php HTTP/1.0" 200 0
domain.tld 123.456.789 - - [14/Apr/2018:10:04:23 +1000] "GET /itdelta/index.php HTTP/1.1" 200 0

Without root strip 1, though, domain.tld/thatapp/index.php returns a 403 access denied; presumably because it's looking for domain.tld/thatapp/index.php at /var/www/theAppWeWant/thatapp/index.php. This assumes I’m interpreting the strip option[0] correctly: that the specified number, in this case 1, of segments will be removed from the beginning of the requested path. Therefore, /thatapp/index.php turns into /index.php, which will be looked for in the root /theAppWeWant. Although, I’m not sure why this doesn't return a 404 instead because /thatapp doesn’t exist under the location /theAppWeWant so maybe I’m not interpreting strip correctly?
And domain.tld/thatapp returns a 404; presumably for the same reason that 404s are being returned even with root strip 1 (i.e., the problem we’re trying to fix).

Code:
# tail -f /var/www/logs/access.log
domain.tld 123.456.789 - - [14/Apr/2018:10:10:06 +1000] "GET /itdelta/index.php HTTP/1.1" 403 0
domain.tld 123.456.789 - - [14/Apr/2018:10:10:07 +1000] "GET /itdelta HTTP/1.1" 404 0
domain.tld 123.456.789 - - [14/Apr/2018:10:10:09 +1000] "GET /itdelta HTTP/1.1" 404 0
domain.tld 123.456.789 - - [14/Apr/2018:10:10:15 +1000] "GET /itdelta/index.php HTTP/1.1" 403 0
domain.tld 123.456.789 - - [14/Apr/2018:10:10:16 +1000] "GET /itdelta/index.php HTTP/1.1" 403 0

[0] https://man.openbsd.org/httpd.conf.5#strip
strip number
Strip number path components from the beginning of the request path before looking up the stripped-down path at the document root.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem installing apache-httpd-2.4.23 on OpenBSD 6.0-current lobueb OpenBSD Packages and Ports 5 28th September 2016 05:09 PM
Apache to Httpd frcc OpenBSD General 2 7th September 2015 05:49 PM
declare same alias twice, alias values are different, why ? cq04cw Programming 5 29th March 2011 01:24 PM
Apache : httpd could not be started lalebarde General software and network 13 13th November 2008 11:51 PM
Mounting NAS as apache alias directory Yuka FreeBSD General 7 18th July 2008 02:58 PM


All times are GMT. The time now is 08:40 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick