grunt-connect-proxy icon indicating copy to clipboard operation
grunt-connect-proxy copied to clipboard

Getting 400 Bad request: "You're speaking plain HTTP to an SSL-enabled server port." error.

Open Siim opened this issue 10 years ago • 21 comments

Hi!

I have some configuration issues on OSX Mavericks: if I try to proxy some requests to https server then I get 400 Bad request. Here is the full message:

Bad Request

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

I thought that if I set https option to true then the proxy will handle it. I also configured the client app server to use SSL connection and even this will result the same error:

Here is my configuration:

module.exports = {
    nodePort: 3000,
    dataSource: 'proxy', 
    proxy: {
        proxies: [
            {
                context: '/test',
                host: 'localserver.lan',
                port: 443,
                https: true,
                changeOrigin: false
            }
        ]
    }
};

Siim avatar Oct 14 '14 10:10 Siim

+1

Same issue

Roll back to 0.1.10 which doesn't have this issue.

Skinner927 avatar Nov 04 '14 19:11 Skinner927

+1

Can also confirm this is a regression from 0.1.10

gazoakley avatar Dec 08 '14 14:12 gazoakley

+1

Also a problem on Ubuntu 14.04; 0.1.10 works as expected.

jan-pieter avatar Dec 22 '14 11:12 jan-pieter

+1

uxtracer avatar Dec 24 '14 07:12 uxtracer

+1

omanizer avatar Jan 06 '15 20:01 omanizer

I'm also affected by this, can't rollback to 0.1.10 because then my wss proxy doesn't work. I found this line https://github.com/drewzboto/grunt-connect-proxy/blob/master/tasks/connect_proxy.js#L53 and the next to be a bit odd. The target should have a protocol, and secure is only about certificate validation (in the case you want to mitm the https). Maybe this changed from previous versions of http-proxy, but I think for HTTP->HTTPS proxying you only need to have a https:// target.

pschyska avatar Jan 13 '15 12:01 pschyska

+1

SeyZ avatar Jan 21 '15 19:01 SeyZ

+1 Reverted to 0.1.10 - no issues there.

On Ubuntu 14.04.

aurelin avatar Feb 02 '15 14:02 aurelin

Has anyone forked and fixed this issue?

micah-williamson avatar Mar 09 '15 16:03 micah-williamson

+1

Stratus3D avatar Apr 09 '15 20:04 Stratus3D

The dude made a new version 14 days ago (after almost a year) and didn't fix this?

micah-williamson avatar May 07 '15 20:05 micah-williamson

@iamchairs Feel free to send in a PR.

The new version was to fix people build which were broken.

ruiaraujo avatar May 07 '15 20:05 ruiaraujo

When will this be addressed?

callmeberzerker avatar Jun 01 '15 12:06 callmeberzerker

@SpearThruster This was mentioned October 14th. I'm guessing it won't be. We've moved to gulp and no longer have these problems.

micah-williamson avatar Jun 01 '15 13:06 micah-williamson

I dug through the source code and found a simple fix:

To your proxy configuration, add protocol: 'https:'. I think I'll send a PR documenting this configuration option.

minznerjosh avatar Jul 15 '15 16:07 minznerjosh

Just ran into this, lost a half-hour before finding @minznerjosh's workaround. Works great, much appreciated.

@drewzboto Thoughts on the workaround above? Can we get this fixed? I am available to provide any additional details as desired.

kofalt avatar Oct 10 '15 21:10 kofalt

Looking through the changes between v0.2.0 and v0.1.10 I found this line:

server: httpProxy.createProxyServer({
  // ...
  secure: proxyOption.https
  // ...
})

In short, I got http => https proxying to work by setting my config like so:

{
  https: false,
  protocol: 'https:'
}

Doing it that way let me proxy my UI's api requests from http://localhost:9000/api to my api at https://localhost:8443/api. I hope that helps someone else.

mrDarcyMurphy avatar Oct 15 '15 20:10 mrDarcyMurphy

:+1: on this! seriously, it sucks!

amir-rahnama avatar Oct 21 '15 19:10 amir-rahnama

Using "grunt-connect-proxy": "0.2.0", was getting The plain HTTP request was sent to HTTPS port while proxying to https.

{
  https: false,
  protocol: 'https:'
}

Did the job for me.

majster avatar Dec 10 '15 17:12 majster

+1 Could this please be fixed or at least be document??

Thanks @minznerjosh @mrDarcyMurphy for the solution!

Frank683 avatar Dec 17 '15 13:12 Frank683

same issue. while generating let'sencrypt certificate for my domain. How to solve this?

MishraSachin avatar Apr 06 '17 09:04 MishraSachin