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

Use correct protocol #1425

Merged
merged 1 commit into from
Apr 16, 2018
Merged

Use correct protocol #1425

merged 1 commit into from
Apr 16, 2018

Conversation

Systho
Copy link
Contributor

@Systho Systho commented Apr 12, 2018

Currently we can run webpacker in either http or https mode.
But if we run webpacker in http mode but access it through a reverse proxy handling https, then it will break because the reverse proxy will have set HTTP_X_FORWARDED_PROTO to https and webpack-dev-server will try to understand the request as a secured one.

We must override X_FORWARDED_PROTO in the same way as we override the other headers.

In the meantime I'm using this initializer as a workaround doing exactly the same work as this PR :

# config/initializers/webpacker.rb
require "webpacker/dev_server_proxy.rb"

module Webpacker::DevServerProxy::ProtoOverride
  def perform_request(env)
      env["HTTP_X_FORWARDED_PROTO"] = Webpacker.dev_server.protocol
      super(env)
  end
end
Webpacker::DevServerProxy.include Webpacker::DevServerProxy::ProtoOverride

Currently we can run webpacker in either http or https mode.
But if we run webpacker in http mode but access it through a reverse proxy handling https, then it will break because the reverse proxy will have set HTTP_X_FORWARDED_PROTO to https and webpack-dev-server will try to understand the request as a secured one.

We must override X_FORWARDED_PROTO in the same way as we override the other headers.

In the meantime I'm using this initializer as a workaround  doing exactly the same work as this PR :

```ruby
# config/initializers/webpacker.rb
require "webpacker/dev_server_proxy.rb"

module Webpacker::DevServerProxy::ProtoOverride
  def perform_request(env)
      env["HTTP_X_FORWARDED_PROTO"] = Webpacker.dev_server.protocol
      super(env)
  end
end
Webpacker::DevServerProxy.include Webpacker::DevServerProxy::ProtoOverride

```
@Systho
Copy link
Contributor Author

Systho commented Apr 12, 2018

might be duplicate of #1420 (sorry I just wanted to share our workaround)

@chrisjohnson
Copy link
Contributor

Glad to see I'm not crazy! Funny that we both ran into the same issue around the same time

@gauravtiwari gauravtiwari merged commit acd5d32 into rails:master Apr 16, 2018
@gauravtiwari
Copy link
Member

thanks @Systho

gauravtiwari pushed a commit that referenced this pull request Apr 29, 2018
Currently we can run webpacker in either http or https mode.
But if we run webpacker in http mode but access it through a reverse proxy handling https, then it will break because the reverse proxy will have set HTTP_X_FORWARDED_PROTO to https and webpack-dev-server will try to understand the request as a secured one.

We must override X_FORWARDED_PROTO in the same way as we override the other headers.
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 this pull request may close these issues.

3 participants