-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider making rewrite domain-aware #13
Comments
Are you on mac/linux? If so, use single quotes as bash/shell will perform parameter expansion otherwise.. try
|
the three input params should be paths, not full URLs.. except param 2 ("to" address) - that can be a full URL if you explicitly redirecting to a new host (e.g. localhost in your case)
|
So it can't be done then? My ultimate goal is to have I knew lws-redirect wouldn't work for this so I wrote myself a reverse proxy from scratch, This is why I was asking if there was a option that I was unaware of to make it domain aware, and not limited to just paths. |
so requests to a, b, c, d and e.mydomain.com are all forwarded to one
lws-rewrite uses path-to-regexp internally (from the express project), i don't think it's domain-aware - it operates on the path portion only.. I will need to take a deeper look into this.. |
Yes, I have all subdomains directed towards a single IP. I have very many internal servers all running different SPAs or other type of testing servers. And I have 2 servers that are run on port 80 ws --port 80 --stack lws-redirect --redirect "http -> https" And port 443.. This is where I would LOVE to be able to use ws --port 443 --https --key **** --cert **** --stack lws-rewrite --rewrite <all the stuffs> But instead I got a server that loops through a list of domains and ports and basically does const config = [
['a.mydomain.com', 8080],
['b.mydomain.com', 8081],
['c.mydomain.com', 8082],
['d.mydomain.com', 8083],
['e.mydomain.com', 8084],
];
return (req, res) => {
for (const [domain, port] of config) {
const originalURL = new URL(req.url ?? '', `https://${req.headers.host ?? 'localhost'}`);
if (originalURL.host !== domain) {
continue;
}
const requestURL = new URL(originalURL);
requestURL.host = 'localhost';
requestURL.port = String(port);
requestURL.protocol = 'http';
const options = {
...req,
headers: Object.fromEntries(Object.entries(req.headers)), // I don't remember why, but I had to
};
const requestConnection = require('http')
.request(requestURL, options, (response) => {
res.writeHead(response.statusCode ?? 500, response.headers);
response.pipe(res);
})
.on('error', (err) => {
res.writeHead(500);
res.write(String(err));
res.end();
});
req.pipe(requestConnection);
}
} Not the greatest in the world.. but it's keeping me afloat for now.. |
@75lb |
I didn't assign this as high priority since you're the only one to mention the issue so far plus you had a temporary workaound.. |
Closing.. I'm not saying it is not useful but it is beyond the scope of lws-rewrite. |
Just noticed this example, reminded me of what you were trying to achieve.. |
Hello, I think I already know the answer to this after a brief play with cli, and a quick look through the code, but it never hurts to ask.
I was hoping to see
but I was greeted with the lovely error message of
So, yes, I can see by the examples, you guys are expecting first and third params to be the path from server, and not a path including server..
But You never know, there could be some secret option I was not able to find, so thought best to ask.
The text was updated successfully, but these errors were encountered: