Skip to content

Commit

Permalink
hopefully fix some of the stupid BS
Browse files Browse the repository at this point in the history
  • Loading branch information
MotorTruck1221 committed Oct 4, 2024
1 parent c1317db commit f74d139
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 57 deletions.
62 changes: 14 additions & 48 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rammerhead/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.2.72

- Hopefully fix the errors when running behind a reverse proxy

## v1.2.70

- Setup folder properly
Expand Down
3 changes: 2 additions & 1 deletion rammerhead/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rubynetwork/rh",
"version": "1.2.71",
"version": "1.2.72",
"description": "User friendly web proxy powered by testcafe-hammerhead",
"main": "src/index.js",
"type": "module",
Expand All @@ -27,6 +27,7 @@
"homepage": "https://github.com/binary-person/rammerhead#readme",
"dependencies": {
"async-exit-hook": "^2.0.1",
"cookie": "^0.7.1",
"lru-cache": "^7.14.1",
"mime": "^2.5.2",
"sticky-session-custom": "^1.2.0",
Expand Down
30 changes: 24 additions & 6 deletions rammerhead/src/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs';
import os from 'os';
import path from 'path';
import cookie from 'cookie';
import RammerheadJSFileCache from './classes/RammerheadJSFileCache.js';
import RammerheadJSMemCache from './classes/RammerheadJSMemCache.js';

Expand All @@ -25,12 +26,29 @@ export default {
// this function's return object will determine how the client url rewriting will work.
// set them differently from bindingAddress and port if rammerhead is being served
// from a reverse proxy.
getServerInfo: () => ({
hostname: 'localhost',
port: 8080,
crossDomainPort: 8081,
protocol: 'http:'
}),
//getServerInfo: () => ({
// hostname: 'localhost',
// port: 8080,
// crossDomainPort: 8081,
// protocol: 'http:'
//}),
getServerInfo: (req) => {
const { origin_proxy } = cookie.parse(req.headers.cookie || '');
let origin;
try {
origin = new URL(origin_proxy);
} catch (err) {
console.log(err, req.headers.cookie);
origin = new URL(`${req.socket.encrypted ? 'https:' : 'http:'}//${req.headers.host}`);
}
const { hostname, port, protocol } = origin;
return {
hostname,
port,
crossDomainPort: port,
protocol
};
},
// example of non-hard-coding the hostname header
// getServerInfo: (req) => {
// return { hostname: new URL('http://' + req.headers.host).hostname, port: 443, crossDomainPort: 8443, protocol: 'https: };
Expand Down
3 changes: 1 addition & 2 deletions rammerhead/src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ function setup() {
fs.mkdirSync(path.join(import.meta.dirname, '..', 'public'));
}
catch (err) {
//steam roll over errors :D
//console.error('Something went wrong!\n', err)
console.error('Error occured while setting up:', err);
}
}

Expand Down

0 comments on commit f74d139

Please sign in to comment.