Support X-Forwarded-Proto header

Evgeny PisemskySat Mar 29 21:21:00+0300 2025

133d9aa

Support X-Forwarded-Proto header

modules/pastebin/httpserver.scm

6666
          (title ,title)
6767
          (meta (@ (charset "utf-8")))
6868
          (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0")))
69-
          (link (@ (rel "stylesheet") (href "https://unpkg.com/simpledotcss/simple.min.css"))))
69+
          (link (@ (rel "stylesheet") (href "https://cdn.simplecss.org/simple.min.css"))))
7070
         (body ,@body)))
7171
7272
(define (list-handler pb-data-path)

9292
                                           (form (@ (method "post")
9393
                                                    (enctype "multipart/form-data")
9494
                                                    (action "/post"))
95-
                                                 (p (label "Paste content"
96-
                                                           (textarea (@ (name "text")) "")))
97-
                                                 (p (label (input (@ (type "checkbox")
98-
                                                                     (name "showUrl")
99-
                                                                     (value "1")))
100-
                                                           "Show raw URL after paste"))
101-
                                                 (input (@ (type "submit"))))))
95+
                                                 (fieldset (label (@ (for "form-text"))
96+
                                                                  "Paste content")
97+
                                                           (textarea (@ (id "form-text")
98+
                                                                        (name "text")) "")
99+
                                                           (label (@ (for "form-showurl"))
100+
                                                                  (input (@ (type "checkbox")
101+
                                                                            (id "form-showurl")
102+
                                                                            (name "showUrl")
103+
                                                                            (value "1")))
104+
                                                                  "Show raw URL after paste")
105+
                                                           (input (@ (type "submit")
106+
                                                                     (value "Submit")))))))
102107
                            (footer (p (a (@ (href "https://github.com/pisemsky/guile-pastebin")
103108
                                             (target "_blank"))
104109
                                          "Source code")))))))

136141
                     #:code 200
137142
                     #:headers '((content-type . (text/plain))))
138143
                    (lambda (port)
139-
                      (let* ((hostp (assq-ref headers 'host)))
144+
                      (let* ((hostp (assq-ref headers 'host))
145+
                             (proto (assq-ref headers 'x-forwarded-proto)))
140146
                        (put-string
141147
                         port
142148
                         (uri->string
143-
                          (build-uri 'http
149+
                          (build-uri (if (equal? proto "https") 'https 'http)
144150
                                     #:host (car hostp)
145151
                                     #:port (cdr hostp)
146152
                                     #:path (format #f "/raw/~a\r\n"