1 Commits

Author SHA1 Message Date
Alex Schroeder
b64d56a648 Document a curious bug with the Apache configuration 2024-01-27 21:27:17 +01:00
10 changed files with 165 additions and 36 deletions

View File

@@ -6,9 +6,7 @@
<meta name="viewport" content="width=device-width">
<title>Add to {{.Title}}</title>
<style>
html { max-width: 70ch; padding: 2ch; margin: auto; color: #ddd; background-color: #222; }
a { color: #8cf } a:visited { color: #dbf } a:hover { color: #fff }
textarea, input, button { color: #222; background-color: #ddd; border: 1px solid #eee; }
html { max-width: 70ch; padding: 2ch; margin: auto; color: #111; background-color: #ffe; }
form, textarea { width: 100%; }
</style>
</head>

View File

@@ -6,12 +6,11 @@
<meta name="viewport" content="width=device-width">
<title>{{.Title}}</title>
<style>
html { max-width: 70ch; padding: 1ch; margin: auto; color: #ddd; background-color: #222; }
a { color: #8cf } a:visited { color: #dbf } a:hover { color: #fff }
html { max-width: 70ch; padding: 1ch; margin: auto; color: #111; background-color: #ffe; }
body { hyphens: auto; }
del { background-color: #fab }
ins { background-color: #af8 }
pre { white-space: normal; color: #222; background-color: #ddd; border: 1px solid #eee; padding: 1ch }
pre { white-space: normal; background-color: white; border: 1px solid #eee; padding: 1ch }
</style>
</head>
<body>

View File

@@ -6,9 +6,7 @@
<meta name="viewport" content="width=device-width">
<title>Editing {{.Title}}</title>
<style>
html { max-width: 70ch; padding: 2ch; margin: auto; color: #ddd; background-color: #222; }
a { color: #8cf } a:visited { color: #dbf } a:hover { color: #fff }
textarea, input, button { color: #222; background-color: #ddd; border: 1px solid #eee; }
html { max-width: 70ch; padding: 2ch; margin: auto; color: #111; background-color: #ffe; }
form, textarea { width: 100%; }
</style>
</head>

View File

@@ -3,10 +3,10 @@
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<title>{{.Title}}</title>
<link>https://example.org/</link>
<managingEditor>jupiter@transjovian.org (Ashivom Bandaralum)</managingEditor>
<webMaster>jupiter@transjovian.org (Ashivom Bandaralum)</webMaster>
<managingEditor>you@example.org (Your Name)</managingEditor>
<webMaster>you@example.org (Your Name)</webMaster>
<atom:link href="https://example.org/view/{{.Name}}.rss" rel="self" type="application/rss+xml"/>
<description>This is the digital garden of Ashivom Bandaralum.</description>
<description>This is the digital garden of Your Name.</description>
<image>
<url>https://example.org/view/logo.jpg</url>
<title>{{.Title}}</title>

View File

@@ -5,7 +5,7 @@
.nh
.ad l
.\" Begin generated content:
.TH "ODDMU-APACHE" "5" "2024-01-17"
.TH "ODDMU-APACHE" "5" "2024-01-27"
.PP
.SH NAME
.PP
@@ -40,13 +40,14 @@ MDCertificateAgreement accepted
<VirtualHost *:80>
ServerName transjovian\&.org
RewriteEngine on
RewriteRule ^/(\&.*) https://%{HTTP_HOST}/$1 [redirect]
RewriteRule "^/(\&.*)" "https://%{HTTP_HOST}/$1" [redirect]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin alex@alexschroeder\&.ch
ServerName transjovian\&.org
SSLEngine on
ProxyPassMatch "^/((view|diff|edit|save|add|append|upload|drop|search)/(\&.*))?$" "http://localhost:8080/$1"
ProxyPassMatch "^/((view|diff|edit|save|add|append|upload|drop|search)/(\&.*))?$"
"http://localhost:8080/$1"
</VirtualHost>
.fi
.RE
@@ -83,13 +84,72 @@ second instead just proxy to the wiki like you did for the second virtual
host: use a copy of the "ProxyPassMatch" directive instead of "RewriteEngine on"
and "RewriteRule".\&
.PP
.SS Allow HTTP for viewing
.PP
When looking at pages, you might want to allow HTTP since no password is
required.\&
.PP
.nf
.RS 4
MDomain transjovian\&.org
MDCertificateAgreement accepted
<VirtualHost *:80>
ServerName transjovian\&.org
RewriteEngine on
ProxyPassMatch "^/((view|diff|search)/(\&.*))?$"
"http://localhost:8080/$1"
RewriteRule "^/((edit|save|add|append|upload|drop)/(\&.*))?$"
"https://%{HTTP_HOST}/$1" [redirect]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin alex@alexschroeder\&.ch
ServerName transjovian\&.org
SSLEngine on
ProxyPassMatch "^/((view|diff|edit|save|add|append|upload|drop|search)/(\&.*))?$"
"http://localhost:8080/$1"
</VirtualHost>
.fi
.RE
.PP
.SS Using a Unix-domain Socket
.PP
Instead of having Oddmu listen on a TCP port, you can have it listen on a
Unix-domain socket.\& This requires socket activation.\& An example of configuring
the service is given in \fIoddmu.\&service(5)\fR.\&
.PP
On the Apache side, you only need to change ProxyMatch directives.\& For instance:
To test just the unix domain socket, use \fIncat(1)\fR:
.PP
.nf
.RS 4
echo -e "GET /view/index HTTP/1\&.1rnHost: localhostrnrn"
| ncat --unixsock /run/oddmu/oddmu\&.sock
.fi
.RE
.PP
On the Apache side, you can proxy to the socket directly.\& This sends all
requests to the socket:
.PP
.nf
.RS 4
ProxyPass "/" "unix:/run/oddmu/oddmu\&.sock|http://localhost/"
.fi
.RE
.PP
Now, all traffic between the web server and the wiki goes over the socket at
"/run/oddmu/oddmu.\&sock".\&
.PP
To test it on the command-line, use a tool like \fIcurl(1)\fR.\& Make sure to provide
the correct servername!\&
.PP
.nf
.RS 4
curl http://transjovian\&.org/view/index
.fi
.RE
.PP
You probably want to serve some static files as well (see \fBServe static files\fR).\&
In that case, you need to use the ProxyPassMatch directive.\&
.PP
.nf
.RS 4
@@ -98,8 +158,24 @@ ProxyPassMatch "^/((view|diff|edit|save|add|append|upload|drop|search)/(\&.*))?$
.fi
.RE
.PP
Now, all traffic between the web server and the wiki goes over the socket at
"/run/oddmu/oddmu.\&sock".\&
There'\&s a curious problem with this expression, however.\& If you use \fIcurl(1)\fR to
get the root path, Apache hangs:
.PP
.nf
.RS 4
curl http://transjovian\&.org/
.fi
.RE
.PP
A workaround is to add the redirect manually and drop the question-mark:
.PP
.nf
.RS 4
RedirectMatch "^/$" "/view/index"
ProxyPassMatch "^/((view|diff|edit|save|add|append|upload|drop|search)/(\&.*))$"
"unix:/run/oddmu/oddmu\&.sock|http://localhost/$1"
.fi
.RE
.PP
.SS Access
.PP

View File

@@ -32,13 +32,14 @@ MDCertificateAgreement accepted
<VirtualHost *:80>
ServerName transjovian.org
RewriteEngine on
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [redirect]
RewriteRule "^/(.*)" "https://%{HTTP_HOST}/$1" [redirect]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin alex@alexschroeder.ch
ServerName transjovian.org
SSLEngine on
ProxyPassMatch "^/((view|diff|edit|save|add|append|upload|drop|search)/(.*))?$" "http://localhost:8080/$1"
ProxyPassMatch "^/((view|diff|edit|save|add|append|upload|drop|search)/(.*))?$" \
"http://localhost:8080/$1"
</VirtualHost>
```
@@ -66,21 +67,84 @@ second instead just proxy to the wiki like you did for the second virtual
host: use a copy of the "ProxyPassMatch" directive instead of "RewriteEngine on"
and "RewriteRule".
## Allow HTTP for viewing
When looking at pages, you might want to allow HTTP since no password is
required.
```
MDomain transjovian.org
MDCertificateAgreement accepted
<VirtualHost *:80>
ServerName transjovian.org
RewriteEngine on
ProxyPassMatch "^/((view|diff|search)/(.*))?$" \
"http://localhost:8080/$1"
RewriteRule "^/((edit|save|add|append|upload|drop)/(.*))?$" \
"https://%{HTTP_HOST}/$1" [redirect]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin alex@alexschroeder.ch
ServerName transjovian.org
SSLEngine on
ProxyPassMatch "^/((view|diff|edit|save|add|append|upload|drop|search)/(.*))?$" \
"http://localhost:8080/$1"
</VirtualHost>
```
## Using a Unix-domain Socket
Instead of having Oddmu listen on a TCP port, you can have it listen on a
Unix-domain socket. This requires socket activation. An example of configuring
the service is given in _oddmu.service(5)_.
On the Apache side, you only need to change ProxyMatch directives. For instance:
To test just the unix domain socket, use _ncat(1)_:
```
echo -e "GET /view/index HTTP/1.1\r\nHost: localhost\r\n\r\n" \
| ncat --unixsock /run/oddmu/oddmu.sock
```
On the Apache side, you can proxy to the socket directly. This sends all
requests to the socket:
```
ProxyPass "/" "unix:/run/oddmu/oddmu.sock|http://localhost/"
```
Now, all traffic between the web server and the wiki goes over the socket at
"/run/oddmu/oddmu.sock".
To test it on the command-line, use a tool like _curl(1)_. Make sure to provide
the correct servername!
```
curl http://transjovian.org/view/index
```
You probably want to serve some static files as well (see *Serve static files*).
In that case, you need to use the ProxyPassMatch directive.
```
ProxyPassMatch "^/((view|diff|edit|save|add|append|upload|drop|search)/(.*))?$" \
"unix:/run/oddmu/oddmu.sock|http://localhost/$1"
```
Now, all traffic between the web server and the wiki goes over the socket at
"/run/oddmu/oddmu.sock".
There's a curious problem with this expression, however. If you use _curl(1)_ to
get the root path, Apache hangs:
```
curl http://transjovian.org/
```
A workaround is to add the redirect manually and drop the question-mark:
```
RedirectMatch "^/$" "/view/index"
ProxyPassMatch "^/((view|diff|edit|save|add|append|upload|drop|search)/(.*))$" \
"unix:/run/oddmu/oddmu.sock|http://localhost/$1"
```
## Access

View File

@@ -6,8 +6,7 @@
<meta name="viewport" content="width=device-width">
<title>Search for {{.Query}}</title>
<style>
html { max-width: 70ch; padding: 2ch; margin: auto; color: #ddd; background-color: #222; }
a { color: #8cf } a:visited { color: #dbf } a:hover { color: #fff }
html { max-width: 70ch; padding: 2ch; margin: auto; color: #111; background-color: #ffe; }
body { hyphens: auto; }
header a { margin-right: 1ch; }
form { display: inline-block; }

View File

@@ -6,8 +6,7 @@
<meta name="viewport" content="width=device-width">
<title>{{.Title}}</title>
<style>
html { max-width: 65ch; padding: 1ch; margin: auto; color: #ddd; background-color: #222; }
a { color: #8cf } a:visited { color: #dbf } a:hover { color: #fff }
html { max-width: 65ch; padding: 1ch; margin: auto; color: #111; background-color: #ffe; }
body { hyphens: auto; }
header a { margin-right: 1ch; }
form { display: inline-block; }
@@ -24,7 +23,7 @@ img { max-width: 100%; }
</main>
<footer>
<address>
Send text via the long-range comms to Ashivom Bandaralum &lt;<a href="mailto:jupiter@transjovian.org">jupiter@transjovian.org</a>&gt;
Comments? Send mail to Your Name <<a href="mailto:you@example.org">you@example.org</a>>
</address>
</footer>
</body>

View File

@@ -6,10 +6,8 @@
<meta name="viewport" content="width=device-width">
<title>Upload File</title>
<style>
html { max-width: 70ch; padding: 2ch; margin: auto; color: #ddd; background-color: #222; }
a { color: #8cf } a:visited { color: #dbf } a:hover { color: #fff }
html { max-width: 70ch; padding: 2ch; margin: auto; color: #111; background-color: #ffe; }
body { hyphens: auto; }
textarea, input, button { color: #222; background-color: #ddd; border: 1px solid #eee; }
form, textarea { width: 100%; }
label { display: inline-block; width: 20ch }
.last { max-width: 20% }

View File

@@ -6,9 +6,7 @@
<meta name="viewport" content="width=device-width">
<title>{{.Title}}</title>
<style>
html { max-width: 70ch; padding: 1ch; margin: auto; color: #ddd; background-color: #222; }
a { color: #8cf } a:visited { color: #dbf } a:hover { color: #fff }
input, button { color: #222; background-color: #ddd; border: 1px solid #eee; }
html { max-width: 70ch; padding: 1ch; margin: auto; color: #111; background-color: #ffe; }
body { hyphens: auto; }
header a { margin-right: 1ch; }
form { display: inline-block; }
@@ -29,7 +27,7 @@ img { max-width: 100%; }
<form role="search" action="/search/{{.Dir}}" method="GET">
<label for="search">Search:</label>
<input id="search" type="text" spellcheck="false" name="q" accesskey="f" placeholder="term #tag title:term blog:true" required>
<input type="submit" value="Go"/>
<button>Go</button>
</form>
</header>
<main id="main">
@@ -38,7 +36,7 @@ img { max-width: 100%; }
</main>
<footer>
<address>
Send text via the long-range comms to Ashivom Bandaralum &lt;<a href="mailto:jupiter@transjovian.org">jupiter@transjovian.org</a>&gt;
Comments? Send mail to Your Name <<a href="mailto:you@example.org">you@example.org</a>>
</address>
</footer>
</body>