Ask Your Question
1

Forward HTTP requests to HTTPS

asked 2017-10-30 18:42:05 +0100

Eric Crockett gravatar image

I've set up my Sage server to run on a public-facing interface and with the 'secure=True' option. I'm also forwarding port 443 to this secure server. This works reasonably well, except that the only way to access the server is with an explicit "https://" (no port number required since I'm forwarding 443). I'd like to just be able to type my hostname (without the protocol) and be automatically redirected to the secure portal. Is there some way to configure the underlying web server to do this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-10-30 18:49:28 +0100

tmonteil gravatar image

updated 2017-10-30 18:52:02 +0100

This is somehow unrelated to Sage, you need to have a webserver listening on port 80 that forwards to port 443.

For example, if you are running nginx, you can add the following in your configuration:

server {
    server_name your_hostname.net ;
    listen 80 ;
    location '/' {
        return 301 https://$server_name$request_uri ;
    }
}

We use that for the site ask.sagemath.org ;)

edit flag offensive delete link more

Comments

I'm using the sagemath-upstream-binary package from ppa:aims/sagemath, so I didn't explicitly install or configure any web server. What web server is used with that distribution, and where can the config files be found?

Eric Crockett gravatar imageEric Crockett ( 2017-10-30 18:59:08 +0100 )edit

You can install the nginx ubuntu package, and put the previous lines in the /etc/nginx/sites-enabled/sageredirect file. That said, i am not sure that having Sage notebook directly listen to a public port is a safe idea, i would use a real webserver (like nginx) in front, especially if you plan to make the address public.

tmonteil gravatar imagetmonteil ( 2017-10-30 19:03:56 +0100 )edit

I see. So the notebook is itself a web server (not running on top of apache or similar). I just set up a basic nginx/apache web server that forwards requests to the sage notebook? Is that the basic idea?

Eric Crockett gravatar imageEric Crockett ( 2017-10-30 19:08:10 +0100 )edit

Yes, the notebook is a itself a webserver (which is nothing but a program that listens to some port for http requests). Regarding using a bulletproof webserver in front as a proxy, this is what i would have done, though i have never set up a public notebook, so i encourage people that did it to withness about their experience here. You could also look at wiki.sagemath.org and look for some documentation about that.

tmonteil gravatar imagetmonteil ( 2017-10-30 19:24:59 +0100 )edit

There are several places on the wiki about setting up a public server, and the somewhat not used sage-notebook Google group. People have definitely set up proxies for the sagenb server, though, and pretty easily if you are someone who knows about how to do such things. It's not as modern as could be, but works out the box (hopefully still with Sage 8.0 too) for this purpose.

kcrisman gravatar imagekcrisman ( 2017-10-30 20:21:59 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-10-30 18:42:05 +0100

Seen: 746 times

Last updated: Oct 30 '17