Skip to content
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

The proxy feature does not work when using HTTPS. #719

Closed
dwjohnston opened this issue Aug 16, 2021 · 3 comments · Fixed by #688
Closed

The proxy feature does not work when using HTTPS. #719

dwjohnston opened this issue Aug 16, 2021 · 3 comments · Fixed by #688

Comments

@dwjohnston
Copy link

dwjohnston commented Aug 16, 2021

Steps to reproduce the issue, if applicable. Include the actual command and output and/or stack trace.

Full repro here:
https://github.com/dwjohnston/http-server-issue/tree/master

I start a server with

http-server --proxy https://localhost:8080? ./lib -S -C localhost.crt -K localhost.key -p 8080

What did you expect to happen?

I should be able to access index.html at https://localhost:8080/foobar

Instead, I get a 404.

$ http-server --proxy https://localhost:8080? ./lib -S -C localhost.crt -K localhost.key -p 8080
Starting up http-server, serving ./lib through https
Available on:
  https://127.0.0.1:8080
  https://192.168.1.105:8080
Unhandled requests will be served from: https://localhost:8080?
Hit CTRL-C to stop the server
[2021-08-16T02:33:27.616Z]  "GET /foobar" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
(node:33863) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
[2021-08-16T02:33:27.636Z]  "GET /foobar" Error (404): "self signed certificate"
[2021-08-16T02:33:27.636Z]  "GET /foobar" Error (404): "Not found"
[2021-08-16T02:33:27.637Z]  "GET /foobar" Error (404): "Not found"
[2021-08-16T02:33:28.568Z]  "GET /foobar" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
[2021-08-16T02:33:28.573Z]  "GET /foobar" Error (404): "self signed certificate"
[2021-08-16T02:33:28.573Z]  "GET /foobar" Error (404): "Not found"
[2021-08-16T02:33:28.573Z]  "GET /foobar" Error (404): "Not found"

Tell us about your environment
http-server 13.0.0
node 10.23.0
node 14.17.0

@dwjohnston
Copy link
Author

It looks like the issue is that http-proxy does not allow self signed certificates:
https://github.com/http-party/node-http-proxy/blob/9b96cd725127a024dabebec6c7ea8c807272223d/test/lib-https-proxy-test.js#L152

@dwjohnston
Copy link
Author

dwjohnston commented Aug 16, 2021

^ Oh no, so just setting secure to false will solve that. It just won't verify the certificate.

@dwjohnston
Copy link
Author

I have created a PR here #720

I think there's a question of whether you want that proxy SSL verification to always be false, or you want to make that available as an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant