Skip to content

Commit

Permalink
Added error page.
Browse files Browse the repository at this point in the history
  • Loading branch information
outment authored Feb 24, 2025
1 parent f5acf65 commit 2368599
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
74 changes: 74 additions & 0 deletions 503.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Proxy Route Failure</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
color: #333;
}

.container {
padding: 2rem;
}

h2 {
color: #007bff;
}

h1 {
color: #007bff;
}

.endpoint {
background-color: #fff;
border: 1px solid #ddd;
margin: 1rem 0;
padding: 1rem;
border-radius: 4px;
}

.endpoint code {
background-color: #f4f4f4;
padding: 0.2rem;
border-radius: 4px;
}

.request-method {
font-weight: bold;
color: #333;
}

.response {
background-color: #f8f9fa;
padding: 1rem;
margin-top: 1rem;
border-radius: 4px;
}
</style>
</head>

<body>
<div class="container">
<div class="endpoint">
<h1>Proxy Route Failure</h3>
<p class="request-method">GET [REDACTED]</p>
<p>PFPRXY failed to connect to Project Furina Servers.</p>

<h2>Further Information</h4>
<div class="response">
<pre>Project Furina Proxy attempted to connect to the target machine, but the target machine did not respond in a timely matter.</pre>
<pre>ERROR: PFPRXY_CONNECTION_TIMEOUT</pre>
</div>
<i>PFPRXY encountered a connection error, therefore you are not able to access this website at the moment.</i>
</div>
</div>
</body>

</html>
9 changes: 9 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const net = require('net')
const http = require('http')
const fs = require('fs')
const httpProxy = require('http-proxy')

const PORT = process.env.PORT || 3000
const errorPage = fs.readFileSync('503.html', 'utf8')

function createProxyAgent(req) {
return new http.Agent({
Expand All @@ -17,6 +19,13 @@ function createProxyAgent(req) {

const proxy = httpProxy.createProxyServer({})

proxy.on('error', (err, req, res) => {
if (res) {
if (!res.headersSent) res.writeHead(503, { 'Content-Type': 'text/html' })
res.end(errorPage)
}
})

const server = http.createServer((req, res) => {
const targetUrl = 'http://147.185.221.25:33187'
const agent = createProxyAgent(req)
Expand Down

0 comments on commit 2368599

Please sign in to comment.