Reverse proxy fixes and changes
This commit is contained in:
parent
3063358ecf
commit
c5f4d281d5
|
@ -144,7 +144,9 @@ export default class GeminiServer {
|
||||||
|
|
||||||
if (matches) {
|
if (matches) {
|
||||||
Promise.resolve(p.handler.handle(url, p.basePath, socket)).then(res => {
|
Promise.resolve(p.handler.handle(url, p.basePath, socket)).then(res => {
|
||||||
socket.write(res);
|
if (res) {
|
||||||
|
socket.write(res);
|
||||||
|
}
|
||||||
socket.end();
|
socket.end();
|
||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
return;
|
return;
|
||||||
|
|
10
README.gmi
10
README.gmi
|
@ -1,3 +1,7 @@
|
||||||
|
# Astronomical Theater
|
||||||
|
A Node.js Gemini server and proxy.
|
||||||
|
|
||||||
|
Do not use.
|
||||||
|
|
||||||
### We require SNI!
|
### We require SNI!
|
||||||
The Gemini spec requires clients to implement SNI. This server requires SNI to connect.
|
The Gemini spec requires clients to implement SNI. This server requires SNI to connect.
|
||||||
|
@ -37,6 +41,12 @@ openssl genrsa -out private-key.pem 2048
|
||||||
openssl req -new -sha256 -key private-key.pem -out csr.pem
|
openssl req -new -sha256 -key private-key.pem -out csr.pem
|
||||||
# Self-sign, generating cert
|
# Self-sign, generating cert
|
||||||
openssl x509 -req -in csr.pem -signkey private-key.pem -out public-cert.pem
|
openssl x509 -req -in csr.pem -signkey private-key.pem -out public-cert.pem
|
||||||
|
|
||||||
|
# For debugging clients, it can be useful to start a openssl server with these certs:
|
||||||
|
openssl s_server -key private-key.pem -cert public-cert.pem -accept 1965
|
||||||
|
|
||||||
|
# And of course creating a client with openssl. The -servername is needed for SNI
|
||||||
|
openssl s_client -connect example.com:1965 -servername example.com
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import DefaultHandler from "./handlers/default.js";
|
||||||
import ReverseProxyHandler from "./handlers/revproxy.js";
|
import ReverseProxyHandler from "./handlers/revproxy.js";
|
||||||
|
|
||||||
// import {, staticFileHandler} from "./main.js";
|
// import {, staticFileHandler} from "./main.js";
|
||||||
|
// If you'r going to be reverse-proxying a server with a self-signed cert, you need
|
||||||
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
|
||||||
|
|
||||||
const server = new GeminiServer({
|
const server = new GeminiServer({
|
||||||
// port: 1965
|
// port: 1965
|
||||||
|
|
|
@ -81,8 +81,10 @@ export default class ReverseProxyHandler extends DefaultHandler {
|
||||||
|
|
||||||
console.log(`Attempting to proxy ${toServe}.`);
|
console.log(`Attempting to proxy ${toServe}.`);
|
||||||
try {
|
try {
|
||||||
await geminiReq(toServe, socket)
|
// Add back url.search
|
||||||
return "";
|
await geminiReq(toServe + url.search, socket);
|
||||||
|
// geminiReq has already handled writing data back to the stream
|
||||||
|
return false;
|
||||||
}catch (err) {
|
}catch (err) {
|
||||||
console.log("Something went wrong with the proxy.");
|
console.log("Something went wrong with the proxy.");
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
Loading…
Reference in New Issue