|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
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 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" } } |
|
|||
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" } } |
|
|||
Yeah, acme works for me, too, on the same box; same server. But this location isn't being parsed at all for some reason.
|
|
|||
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. |
|
|
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 |