spdy-http2 / node-spdy

SPDY server on Node.js
2.81k stars 196 forks source link

Redirect http requests to https with spdy #293

Open SamuelGaona opened 7 years ago

SamuelGaona commented 7 years ago

How do I get to work this?

muety commented 7 years ago

+1

dannluciano commented 7 years ago

I agree that you need do this in webserver (nginx/apache)

A example in nginx:

server {
       listen         80;
       server_name    my.domain.com;
       return         301 https://$server_name$request_uri;
}

server {
       listen         443 ssl;
       server_name    my.domain.com;

       [....]
}
codepunkt commented 7 years ago

Some of us might not want to have an apache or nginx in front of our node app. How can this be done using spdy directly?

muety commented 7 years ago

Some of us might not want to have an apache or nginx in front of our node app. How can this be done using spdy directly?

Add a second server listener using the "normal" node http (1.1) package on port 80, which returns a 301 with https://youraddress for every request.

codepunkt commented 7 years ago

@n1try sounds good, thanks :)

daviddias commented 7 years ago

That is a way to do it, but it might not be the solution you are looking for since it will stop you from using spdy/h2 benefits, i.e: you won't be able to do push streams.

This module API maps to Node.js http module, the example here https://github.com/spdy-http2/node-spdy#examples should be the answer you are looking for, have you tried it so far?