Giter VIP home page Giter VIP logo

Comments (4)

Robinlovelace avatar Robinlovelace commented on July 26, 2024

Yes, very happy with that. It's something that I've noticed when sharing the link, people access it from a multitude of URLs. 👍

from pct-shiny.

mvl22 avatar mvl22 commented on July 26, 2024

Yes, you should be using a canonical link, and https with www is best practice, redirecting all others to that, and retaining the local path.

	ServerAlias pct.bike

	# Force bare domain to be www instead
	RewriteEngine on
	RewriteCond %{HTTP_HOST} ^pct\.bike$ [NC]
	RewriteRule (.*) https://www.pct.bike%{REQUEST_URI}

from pct-shiny.

nikolai-b avatar nikolai-b commented on July 26, 2024

Thanks but sadly we have haproxy so we can't use your nginx config. I don't know haproxy as well but I've added:

  frontend http-in
  	bind ipv4@:80
  	bind ipv6@:80
  	# option httplog
  	option forwardfor
+ 
+ 	# Redirect http://(www.).pct.bike/a/b/c -> https://www.pct.bike/a/b/c
+ 	redirect prefix https://www.pct.bike code 301
+ 
  	acl letsencrypt-acl path_beg /.well-known/acme-challenge/
  	use_backend letsencrypt-backend if letsencrypt-acl
  
  frontend http-ssl-in
  	bind ipv4@:443 ssl crt /etc/haproxy/certs/pct.bike.pem
  	bind ipv6@:443 ssl crt /etc/haproxy/certs/pct.bike.pem
+ 
+ 	# Detect the host name in the “ pct.bike ” header
+ 	acl nonww-acl hdr(host) -i pct.bike
+ 
+ 	# Redirect https://pct.bike/a/b/c -> https://www.pct.bike/a/b/c
+ 	http-request redirect prefix https://www.pct.bike code 301 if nonww-acl
+ 

and now they all seem to work. Note to self: haproxy is on all our production servers so the config needs to be changed in both places or it only intermittently works 🤦‍♂️.

from pct-shiny.

Robinlovelace avatar Robinlovelace commented on July 26, 2024

Great work @nikolai-b, confirmed as follows:

system("curl -s -L -D - http://pct.bike -o /dev/null -w '%{url_effective}'", intern = TRUE)
#>  [1] "HTTP/1.1 301 Moved Permanently\r"              
#>  [2] "Content-length: 0\r"                           
#>  [3] "Location: https://www.pct.bike/\r"             
#>  [4] "Connection: close\r"                           
#>  [5] "\r"                                            
#>  [6] "HTTP/1.1 200 OK\r"                             
#>  [7] "X-Powered-By: Shiny Server\r"                  
#>  [8] "Accept-Ranges: bytes\r"                        
#>  [9] "Cache-Control: public, max-age=0\r"            
#> [10] "Last-Modified: Mon, 03 Feb 2020 22:04:17 GMT\r"
#> [11] "ETag: W/\"14e7-1700d153233\"\r"                
#> [12] "Content-Type: text/html; charset=UTF-8\r"      
#> [13] "Content-Length: 5351\r"                        
#> [14] "Vary: Accept-Encoding\r"                       
#> [15] "Date: Fri, 14 Feb 2020 09:17:47 GMT\r"         
#> [16] "Set-Cookie: SERVERID=hex_3838; path=/\r"       
#> [17] "Cache-control: private\r"                      
#> [18] "\r"                                            
#> [19] "https://www.pct.bike/"

Created on 2020-02-14 by the reprex package (v0.3.0)

from pct-shiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.