Comments (9)
Many thanks, sorry I never submitted a pull request.
from node-unblocker.
Good catch. Do you think you can put together a unit test and/or fix for this?
from node-unblocker.
It looks like the problem is unblocker.js
on line 105:
https://github.com/nfriedly/node-unblocker/blob/master/lib/unblocker.js#L105
clientRequest.protocol = clientRequest.protocol || clientRequest.connection.encrypted ? 'https' : 'http';
in my test on an https connection, before line 105, both clientRequest.protocol
and clientRequest.connection.encrypted
are undefined
so clientRequest.protocol
is being incorrectly set to 'http'
.
If I hardcode clientRequest.protocol
to 'https'
https://www.optimcore.com/proxy/http://example.com is correctly redirected to https://www.optimcore.com/proxy/http://example.com/
Let me know if this looks like I'm on the right track and I will continue. How would I go about correctly determining an encrypted connection. The comments state // default to express's more advanced version of this when available (handles X-Forwarded-Protocol headers))
. Is this available now?
from node-unblocker.
Yea, it sounds like you're on the right track. I think the clientRequest.connection.encrypted
setting is/was an undocumented feature that may have been removed in a more recent node.js :/
Are you using Express.js? If so, then clientRequest.protocol
should be set, though, - see http://expressjs.com/en/4x/api.html#req.protocol (although perhaps they were depending on the same undocumented feature).
If there isn't a straightforward way to make it work with a complete URL in the redirect, though, you could look at just doing relative redirects (e.g.: Location: /proxy/http://example.com/
) - it's not RFC compliant, which is why I tried to avoid it initially, but it works in practice - ever browser out there handles it correctly. There may be a few broken tests that will have to be updated if we go that route.
from node-unblocker.
I'm using a standard AWS Elastic Beanstalk Node.js application so as far as I'm aware I'm not using Express.js. Also it's seems over the top to have to reply on a dependency to determine if the request is secure.
I've done a bit of Googling and I can't find any up to date docs or recent StackOverflow posts outlining how to determine if a request is secure.
How do I run the tests, so I can fix this using relative redirects as you suggest?
I will be on holiday all of next week and as the request on my server will always be secure I've hardcoded clientRequest.protocol
as 'https'
. This obviously isn't a fix for everyone, but it's a quick workaround for me for now.
from node-unblocker.
Right, sorry, didn't mean to imply that you should be running express, I was more just curious if this was an issue that affected it as well.
The command npm test
should work to run the tests; I don't think there are any extra requirements beyond grabbing the source from github and running npm install
.
Glad to hear that you have a quick fix; I'll do some poking around and see what I can come up with, although I'm at work now and have family coming in later today, so it might also take me a bit of time to get to it.
What version of Node.js are you running on AWS?
from node-unblocker.
No worries, I didn't mean to imply anything bad. I'm new to Node.js so I don't really understand about Express etc.
I've just checked AWS and I'm running Node.js version 4.3.0. There's more info about Elastic Beanstalk Node.js configurations here. Wikipedia says the latest stable release of Node.js is 5.9.1, so AWS is quite behind. Do you think this could be an issue?
Have a great Easter with your family :)
from node-unblocker.
4.3 is the long-term support release, so it isn't as bad as it sounds.
from node-unblocker.
BTW, I released a fix for this in v2.2.0. Sorry it took so long. There's a test in place, so it shouldn't break again.
from node-unblocker.
Related Issues (20)
- Weird Redirect when deploying with openode.io HOT 2
- Error HOT 1
- Discord isn't working. HOT 5
- Discord link HOT 2
- Next.js support HOT 3
- maleik2
- JustAguy HOT 1
- In Search Of A Proxy HOT 2
- Setting a static URL without typing it after the prefix HOT 7
- Google safe-browsing flags unblocker as phishing
- Proxy not working with Nike.com and Cloudflare HOT 2
- My administrator's website still blocks it even when I use unblockernode
- Z_DATA_ERROR HOT 7
- use node-unblocker in client sveltekit without node js HOT 1
- how to use node-unblocker with https-proxy-agent HOT 1
- sometime error and stuck when use in docker HOT 3
- https://www.youtube.com/embed/XGxIE1hr0w4 --This type of URL cannot be proxied HOT 8
- URL PATH - [feature] HOT 6
- how to add ads in unblocked website HOT 3
- how to bypass cloudflare Human Veriication HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-unblocker.