redo proxy a bit

This commit is contained in:
zefie
2025-07-22 17:06:56 -04:00
parent e302a4f773
commit 69007f08ac
2 changed files with 85 additions and 60 deletions

View File

@@ -2,34 +2,59 @@ minisrv_service_file = true;
request_is_async = true;
proxyUrl = minisrv_config.services[service_name].wrp_url;
if (!proxyUrl.endsWith('/')) {
proxyUrl += '/';
}
if (!request_headers.query.url) {
if (!proxyUrl) {
headers = `200 OK
Content-Type: text/html`;
Content-Type: text/html
wtv-expire-all: wtv-proxy:/`;
data = `
<html>
<head>
<head>
<title>Web Rendering Proxy</title>
</head>
<body bgcolor="#191919" text="#44cc55" link="36d5ff" vlink="36d5ff">
</head>
<body bgcolor="#191919" text="#44cc55" link="36d5ff" vlink="36d5ff">
<h1>Web Rendering Proxy</h1>
<p>Welcome to the Web Rendering Proxy.<br>Please provide a valid URL to render.</p>
Sorry, the Web Rendering Proxy is not enabled on this service.<br>
</body>
</html>`;
sendToClient(socket, headers, data);
} else {
if (!proxyUrl.endsWith('/')) {
proxyUrl += '/';
}
if (!request_headers.query.url) {
headers = `200 OK
Content-Type: text/html
wtv-expire-all: wtv-proxy:/`;
data = `
<html>
<head>
<title>Web Rendering Proxy</title>
</head>
<body bgcolor="#191919" text="#44cc55" link="36d5ff" vlink="36d5ff">
<h1>Web Rendering Proxy</h1>
<p>Welcome to the Web Rendering Proxy.<br>
Please provide a valid URL to render.</p>
<form method="POST" action="wtv-proxy:/proxy">
<label for="url"> URL:</label>
<input type="text" id="url" name="url" value="https://" size=38>
<input type="hidden" name="z" value="1.0">
<input type="hidden" name="t" value="jpg">
<input type="hidden" name="c" value="256">
<input type="hidden" name="h" value="416">
<input type="hidden" name="w" value="640">
<input type="hidden" name="m" value="ismap">
<input type="submit" value="Go">
</form>
</body>
<hr>
<center>
<a href="wtv-tricks:/tricks">Back to Tricks</a>
</center>
</body>
</html>`
sendToClient(socket, headers, data);
} else {
} else {
if (request_headers.query.err) {
finishPage(`<h1>Error</h1><p>${request_headers.query.err}</p>`).join('<br>');
} else {
@@ -38,6 +63,8 @@ Content-Type: text/html`;
z: request_headers.query.z || '1.0',
t: request_headers.query.t || 'jpg',
c: request_headers.query.c || '256',
h: request_headers.query.h || '416',
w: request_headers.query.w || '640',
m: request_headers.query.m || 'ismap'
});
const fullUrl = proxyUrl + '?' + params.toString();
@@ -61,9 +88,9 @@ Content-Type: text/html`;
.catch(err => { finishPage(`Error fetching page: ${err.message}`); });
}
}
}
}
function process(content) {
if (content.startsWith('<HTML')) {
// success page
@@ -89,12 +116,14 @@ function process(content) {
function finishPage(content) {
headers = `200 OK
Content-Type: text/html`;
Content-Type: text/html
wtv-expire-all: wtv-proxy:/`;
data = `
<html>
<head>
<title>Web Rendering Proxy</title>
</head>
<display nooptions>
<body bgcolor="#191919" text="#44cc55" link="36d5ff" vlink="36d5ff">
<form method="POST" action="wtv-proxy:/proxy">
<label for="url">URL:</label>
@@ -105,13 +134,10 @@ Content-Type: text/html`;
<input type="submit" value="Go">
<input type="submit" name="Fn" value="Bk">
<input type="submit" name="Fn" value="Re">
<a href="/proxy">*</a>
<hr>
${content}
</form>
<hr>
<center>
<a href="/proxy">Start Over</a>
</center>
</body>
</html>`;
sendToClient(socket, headers, data);

View File

@@ -395,13 +395,12 @@
},
"wtv-search": {
"disabled": true,
"port": 1695,
"searxng_url": "http://192.168.11.20:9999/" // replace with your own searxng instance
"port": 1695
// "searxng_url": "" // replace with your own searxng instance
},
"wtv-proxy": {
"disabled": true,
"port": 1696,
"wrp_url": "http://192.168.11.20:8889/" // replace with your own tenox9/wrp
"port": 1696
// "wrp_url": "" // replace with your own tenox9/wrp
},
"pb_services": {
// PC Services for PageBuilder