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

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
            }
        ]
    }
};

About this issue

  • Original URL
  • State: open
  • Created 10 years ago
  • Comments: 21

Most upvoted comments

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.