Skip to content

Redirects #80

Closed
Closed

Description

@cben

[Followup from #6]
TODO: intelligent redirects (and/or rel=canonical) http->https, and .com -> .net.

Want both server-side redirect from server.js and client side for GH Pages https.
Should constrain redirects to known domains, to not mess up 3rd-party forks.

Can I allow HTTP for non-SNI clients? Should I (consider #doc=secret for this case)?
Client-side could fetch redirect.js over https to be sure it works.

Should look into libs for running same routing logic on client and server.
Openshift (and probably Heroku) terminate TLS in the reverse proxy; need to check x-forwarding [https://help.openshift.com/hc/en-us/articles/203263674-What-external-ports-are-available-on-OpenShift-]

After some time it's stable, enable HSTS — should be possible simply by setting response header.
good checklist doc for migration to HTTPS: https://docs.google.com/document/d/1oRXJUIttqQxuxmjj2tgYjj096IKw4Zcw6eAoIKWZ2oQ/edit#

Activity

  1. cben commented on Feb 20, 2015

    @cben
    OwnerAuthor

    Can I allow HTTP for non-SNI clients? Should I (consider #doc=secret for this case)?

    No, that's still unsafe under MitM atacks (replace JS with one leaking tho doc id).

    Should I bother with giving non-SNI users a useful error page? No, because (1) they should be used to same failure mode all over the internet (2) it's not like https will entirely fail for them — they'll get wrong cert error (*.rhcloud.com) and should be able to click-through if they really want.

  2. cben commented on Aug 3, 2015

    @cben
    OwnerAuthor

    Due to #104 (Cloudflare serve huge (7 days) TTL on apex domains),
    I'm want to redirect to www.mathdown.net as my primary domain.

  3. added this to the "beta" milestone on Aug 3, 2015
  4. cben commented on Aug 3, 2015

    @cben
    OwnerAuthor
  5. anpc commented on Aug 12, 2015

    @anpc
  6. cben commented on Oct 4, 2015

    @cben
    OwnerAuthor

    Errors on staging-mathdown.rhcloud.com:

    [2015-10-04T12:01:36.270Z] GET http undefined / < 127.12.91.1 undefined
    /var/lib/openshift/55eeb1ad89f5cf2f21000102/app-root/runtime/repo/redirects.js:31
      host = host.toLowerCase();
                  ^
    TypeError: Cannot call method 'toLowerCase' of undefined
      at Object.computeRedirect (/var/lib/openshift/55eeb1ad89f5cf2f21000102/app-root/runtime/repo/redirects.js:31:15)
      at Server.handleRequest (/var/lib/openshift/55eeb1ad89f5cf2f21000102/app-root/runtime/repo/server.coffee:27:21)
      at Server.emit (events.js:117:20)
      at HTTPParser.parser.onIncoming (http.js:2113:12)
      at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:122:23)
      at Socket.socket.ondata (http.js:1971:22)
      at TCP.onread (net.js:528:27)
    DEBUG: Program coffee server.coffee exited with code 8
    DEBUG: Starting child process with 'coffee server.coffee'
    HttpServer up, e.g. http://localhost:8080/?doc=demo
    

    caused by haproxy not providing host header.
    I need a test for that.

  7. reopened this on Oct 4, 2015
  8. cben commented on Oct 4, 2015

    @cben
    OwnerAuthor

    Fixed by 01e6ca9, confirmed in staging.
    Pushing to prod app now.

  9. cben commented on Oct 4, 2015

    @cben
    OwnerAuthor

    Works in prod.

  10. cben commented on Oct 6, 2015

    @cben
    OwnerAuthor

    Uptimerobot shows the 3 redirected domains as "down" since this change.
    Manual inspection shows that it's fine.
    Alas, while Uptimerobot shows "reason" for previous outages, this time it doesn't.
    And it doesn't clearly document how it interprets 3xx responses.

    Uptimerobot uses HEAD requests, which I haven't tested.
    Playing with curl raises one suspicion:

    ~/mathdown (gh-pages) $ curl -v -X GET -H 'Host: mathdown.com' http://mathdown.com/foo
    * Hostname was NOT found in DNS cache
    *   Trying 54.173.37.20...
    * Connected to mathdown.com (54.173.37.20) port 80 (#0)
    > GET /foo HTTP/1.1
    > User-Agent: curl/7.38.0
    > Accept: */*
    > Host: mathdown.com
    > 
    < HTTP/1.1 301 Moved Permanently
    < Date: Tue, 06 Oct 2015 10:03:57 GMT
    < Location: https://www.mathdown.net/foo
    < Cache-control: private
    < Set-Cookie: GEAR=local-55ee99710c1e662f8b000013; path=/
    < Content-Length: 0
    < Content-Type: text/plain
    < 
    * Connection #0 to host mathdown.com left intact
    
    ~/mathdown (gh-pages) $ curl -v -X HEAD -H 'Host: mathdown.com' http://mathdown.com/foo
    * Hostname was NOT found in DNS cache
    *   Trying 54.173.37.20...
    * Connected to mathdown.com (54.173.37.20) port 80 (#0)
    > HEAD /foo HTTP/1.1
    > User-Agent: curl/7.38.0
    > Accept: */*
    > Host: mathdown.com
    > 
    < HTTP/1.1 301 Moved Permanently
    < Date: Tue, 06 Oct 2015 10:04:06 GMT
    < Location: https://www.mathdown.net/foo
    < Cache-control: private
    < Set-Cookie: GEAR=55ee9a9a0c1e66181b000197-mathdown; path=/
    < Content-Type: text/plain
    * no chunk, no close, no size. Assume close to signal end
    < 
    * Closing connection 0
    

    That * no chunk, no close, no size. Assume close to signal end part is suspicious. Am I doing HTTP wrong? I do call res.end() on redirects.
    It refers to the response not containing a Content-Length or "Transfer-Encoding: chunked" header (which I do send for a GET). According to http://sourceforge.net/p/curl/bugs/1124/, these are not needed in a HEAD response — it has an intrinsic length of 0 — and curl has been fixed to understand that. Except turns out the fix applied to --head but not to -X HEAD:

    ~/mathdown (gh-pages) $ curl -v --head -H 'Host: mathdown.com' http://mathdown.com/foo
    * Hostname was NOT found in DNS cache
    *   Trying 54.173.37.20...
    * Connected to mathdown.com (54.173.37.20) port 80 (#0)
    > HEAD /foo HTTP/1.1
    > User-Agent: curl/7.38.0
    > Accept: */*
    > Host: mathdown.com
    > 
    < HTTP/1.1 301 Moved Permanently
    HTTP/1.1 301 Moved Permanently
    < Date: Tue, 06 Oct 2015 10:44:59 GMT
    Date: Tue, 06 Oct 2015 10:44:59 GMT
    < Location: https://www.mathdown.net/foo
    Location: https://www.mathdown.net/foo
    < Cache-control: private
    Cache-control: private
    < Set-Cookie: GEAR=55ee9a9a0c1e66181b000197-mathdown; path=/
    Set-Cookie: GEAR=55ee9a9a0c1e66181b000197-mathdown; path=/
    < Content-Type: text/plain
    Content-Type: text/plain
    
    < 
    * Connection #0 to host mathdown.com left intact
    

    [OK, that's documented curl behavior:

      -X, --request <command>
             ... This  option  only changes the actual word used in the HTTP request, it does not alter
             the way curl behaves. So for example if you want to make a proper HEAD request,  using
             -X HEAD will not suffice. You need to use the -I, --head option.
    

    ]

    So I still don't know if uptimerobot is complaining for something real or just the fact I'm redirecting.
    However, I now added a monitor for http://httpbin.org/status/301, which does send Content-Length: 0 on HEAD, and Uptimerobot seems to like it.

  11. cben commented on Oct 6, 2015

    @cben
    OwnerAuthor

    Oh yes, I'm doing HTTP wrong. http://stackoverflow.com/a/18925736/239657:

    The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET.

  12. reopened this on Oct 6, 2015
  13. cben commented on Oct 6, 2015

    @cben
    OwnerAuthor

    Deployed. The Content-Length is returned from Heroku, but RHcloud's proxie(s) are processing the response.
    GET looks fine:

    
    ~/mathdown (gh-pages) $ curl -i -H 'Host: mathdown.com' http://mathdown.net
    HTTP/1.1 301 Moved Permanently
    Date: Tue, 06 Oct 2015 22:03:39 GMT
    Location: https://www.mathdown.net/
    Content-Length: 0
    Cache-control: private
    Set-Cookie: GEAR=local-55ee99710c1e662f8b000013; path=/
    Content-Type: text/plain
    

    but HEAD loses the Content-Length:

    ~/mathdown (gh-pages) $ curl -I -H 'Host: mathdown.com' http://mathdown.net
    HTTP/1.1 301 Moved Permanently
    Date: Tue, 06 Oct 2015 21:53:46 GMT
    Location: https://www.mathdown.net/
    Cache-control: private
    Set-Cookie: GEAR=local-55ee99710c1e662f8b000013; path=/
    Content-Type: text/plain
    

    Anyway, I tried clicking Pause and then Start on these 3 monitors, and now Uptimerobot shows them as up. Either my change still had an effect (but what?) and I just triggered a re-test (which is what I hoped to do by Pause/Start), or it was all a fluke?!
    Oh well.

    Also added an HTTP heroku monitor (which gets redirected) and it's also considered up.

  14. cben commented on Oct 6, 2015

    @cben
    OwnerAuthor

    Nah, "mathdown.net" is now considered down. Reason: "---".
    Whatever.
    One thing I'm now trying (short of deleting these monitors and/or using another monitoring) is using a "keyword" monitor that fetches and greps the response (ie GET instead of HEAD).

  15. cben commented on Oct 7, 2015

    @cben
    OwnerAuthor

    Changed most monitors to "keyword" monitors doing GET.
    Today:

    The monitor www.mathdown.com 30m (https://www.mathdown.com) is currently DOWN (Keyword Does Not Exist).

    Whatever. www.mathdown.com is clearly up, both in-browser and according to curl.
    I changed Pingdom to https://mathdown.net which also involves a redirect. So far it's "up".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions