Notion of 'Host' header #10

Closed
opened 2019-11-08 13:39:51 +01:00 by mrngm · 1 comment
Collaborator

The templates use net/http.Request.Host to format the URLs on the index page. If you run this behind a reverse proxy (and don't forward or set the Host header), this will print the listen address.

The templates use `net/http.Request.Host` to format the URLs on the index page. If you run this behind a reverse proxy (and don't forward or set the `Host` header), this will print the listen address.
Author
Collaborator

In my local install, I've also patched the index template to use https anchors.

diff --git a/assets/templates/html/index.html.tmpl b/assets/templates/html/index.html.tmpl
index 7eae1d1..e763a98 100644
--- a/assets/templates/html/index.html.tmpl
+++ b/assets/templates/html/index.html.tmpl
@@ -9,12 +9,12 @@ the command line.
 ## USAGE
 
     # Upload a file
-    curl -F'file=@yourfile.png' <a href="{{.Request.Host}}">{{.Request.Host}}</a>
+    curl -F'file=@yourfile.png' <a href="//{{.Request.Host}}">https://{{.Request.Host}}</a>
 
     # Shorten a URL
-    curl -F'shorten=http://example.com/some/long/url' <a href="{{.Request.Host}}">{{.Request.Host}}</a>
+    curl -F'shorten=http://example.com/some/long/url' <a href="//{{.Request.Host}}">https://{{.Request.Host}}</a>
 
     # Shorten a URL with a token to delete it later
-    curl -F'shorten=http://example.com/some/long/url' -F'deleteToken=' <a href="{{.Request.Host}}">{{.Request.Host}}</a>
+    curl -F'shorten=http://example.com/some/long/url' -F'deleteToken=' <a href="//{{.Request.Host}}">https://{{.Request.Host}}</a>
 </pre>
-{{end}}
\ No newline at end of file
+{{end}}
diff --git a/assets/templates/txt/index.txt.tmpl b/assets/templates/txt/index.txt.tmpl
index ac238f4..7b331b0 100644
--- a/assets/templates/txt/index.txt.tmpl
+++ b/assets/templates/txt/index.txt.tmpl
@@ -7,10 +7,10 @@ the command line.
 ## USAGE
 
     # Upload a file
-    curl -F'file=@yourfile.png' {{.Request.Host}}
+    curl -F'file=@yourfile.png' https://{{.Request.Host}}
 
     # Shorten a URL
-    curl -F'shorten=http://example.com/some/long/url' {{.Request.Host}}
+    curl -F'shorten=http://example.com/some/long/url' https://{{.Request.Host}}
 
     # Shorten a URL with a token to delete it later
-    curl -F'shorten=http://example.com/some/long/url' -F'deleteToken=' {{.Request.Host}}
\ No newline at end of file
+    curl -F'shorten=http://example.com/some/long/url' -F'deleteToken=' https://{{.Request.Host}}
In my local install, I've also patched the index template to use https anchors. ``` diff --git a/assets/templates/html/index.html.tmpl b/assets/templates/html/index.html.tmpl index 7eae1d1..e763a98 100644 --- a/assets/templates/html/index.html.tmpl +++ b/assets/templates/html/index.html.tmpl @@ -9,12 +9,12 @@ the command line. ## USAGE # Upload a file - curl -F'file=@yourfile.png' <a href="{{.Request.Host}}">{{.Request.Host}}</a> + curl -F'file=@yourfile.png' <a href="//{{.Request.Host}}">https://{{.Request.Host}}</a> # Shorten a URL - curl -F'shorten=http://example.com/some/long/url' <a href="{{.Request.Host}}">{{.Request.Host}}</a> + curl -F'shorten=http://example.com/some/long/url' <a href="//{{.Request.Host}}">https://{{.Request.Host}}</a> # Shorten a URL with a token to delete it later - curl -F'shorten=http://example.com/some/long/url' -F'deleteToken=' <a href="{{.Request.Host}}">{{.Request.Host}}</a> + curl -F'shorten=http://example.com/some/long/url' -F'deleteToken=' <a href="//{{.Request.Host}}">https://{{.Request.Host}}</a> </pre> -{{end}} \ No newline at end of file +{{end}} diff --git a/assets/templates/txt/index.txt.tmpl b/assets/templates/txt/index.txt.tmpl index ac238f4..7b331b0 100644 --- a/assets/templates/txt/index.txt.tmpl +++ b/assets/templates/txt/index.txt.tmpl @@ -7,10 +7,10 @@ the command line. ## USAGE # Upload a file - curl -F'file=@yourfile.png' {{.Request.Host}} + curl -F'file=@yourfile.png' https://{{.Request.Host}} # Shorten a URL - curl -F'shorten=http://example.com/some/long/url' {{.Request.Host}} + curl -F'shorten=http://example.com/some/long/url' https://{{.Request.Host}} # Shorten a URL with a token to delete it later - curl -F'shorten=http://example.com/some/long/url' -F'deleteToken=' {{.Request.Host}} \ No newline at end of file + curl -F'shorten=http://example.com/some/long/url' -F'deleteToken=' https://{{.Request.Host}} ```
mrngm closed this issue 2019-11-09 22:28:52 +01:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: electricdusk/rushlink#10
No description provided.