Thursday, November 10, 2005

Configuring HTTP and HTTPS ports, and static content


Yesterday I showed you how to create and start the most minimal Mantissa server possible. If you ran the commands from my previous post, you saw something like this in your terminal:


exarkun@boson:~/Scratch/Run/demo$ axiomatic -d my.axiom mantissa
Password:
Confirm:
exarkun@boson:~/Scratch/Run/demo$ axiomatic -d my.axiom start -n
2005/11/11 01:45 EST [-] Log opened.
2005/11/11 01:45 EST [-] twistd SVN-Trunk (/usr/bin/python 2.4.2) starting up
2005/11/11 01:45 EST [-] reactor class: twisted.internet.selectreactor.SelectReactor
2005/11/11 01:45 EST [-] xmantissa.website.AxiomSite starting on 8080
2005/11/11 01:45 EST [-] Starting factory <xmantissa.website.AxiomSite instance at 0xb6ef2fec>

Awesome, I hear you exclaim. But what does it do, you most likely then complain. A fair question, to be sure!



In this minimal configuration, you have a few things:



  • A web server running on port 8080 serving, at /, a static template consisting primarily of a login link.


  • A login page, linked from /.


  • An administrative account, via which you can log in to this server (the username is "admin@localhost", the password is whatever you typed in at the password prompts earlier).


  • When logged in as the administrative account, a small page containing site statistics (such as number of logins, number of users, etc) and a Python REPL.


I'll cover some of these things in further detail in tomorrow's post. For now, let's go over the things we can do to this server.



Before trying to alter any of the server's configuration, let's see what's there already:


exarkun@boson:~/Scratch/Run/demo$ axiomatic -d my.axiom/ web --list
Configured to use HTTP port 8080.
Configured to use HTTPS port 0 with certificate None
Sessionless plugins:
/static/webadmin => item(DeveloperSite) (prio. 0)
/static/mantissa => file(/usr/lib/python2.4/site-packages/xmantissa/static) (prio. -255)
Sessioned plugins:
/ => item(FrontPage) (prio. -257)
exarkun@boson:~/Scratch/Run/demo$

Here we can see a /static/webadmin/ is being served by a DeveloperSite item (whatever that is) and /static/mantissa/ is being served out of the filesystem from the given path. Additionally, there is a page which requires a session at /, being served by a FrontPage item (whatever that is). Also, we see which ports the server is configured to use. Let's say someone is already using 8080, and we also want to turn on HTTPS:

exarkun@boson:~/Scratch/Run/demo$ axiomatic -d my.axiom/ web --port 8888 --secure-port 8889 --pem-file server.pem
exarkun@boson:~/Scratch/Run/demo$ axiomatic -d my.axiom/ web --list
Configured to use HTTP port 8888.
Configured to use HTTPS port 8889 with certificate server.pem
Sessionless plugins:
/static/webadmin => item(DeveloperSite) (prio. 0)
/static/mantissa => file(/usr/lib/python2.4/site-packages/xmantissa/static) (prio. -255)
Sessioned plugins:
/ => item(FrontPage) (prio. -257)
release@boson:~/run$

server.pem doesn't exist yet, so I guess I'll create that too, using a tool that comes with Vertex (maybe you want to install that, too):

exarkun@boson:~/Scratch/Run/demo$ certcreate -C US -s Massachusetts -c Boston -o 'Divmod, Inc.' -h localhost -e support@localhost -f server.pem
Wrote SSL certificate:
Certificate For Subject:
Common Name: localhost
Organization Name: Divmod, Inc.
Organizational Unit Name: Security
Locality Name: Boston
State Or Province Name: Massachusetts
Country Name: US
Email Address: support@localhost

Issuer:
Common Name: localhost
Organization Name: Divmod, Inc.
Organizational Unit Name: Security
Locality Name: Boston
State Or Province Name: Massachusetts
Country Name: US
Email Address: support@localhost

Serial Number: 1
Digest: 59:1F:25:FF:C9:18:98:31:B2:B8:B9:99:FA:99:4C:D0
1024-bit RSA Key Pair with Hash: 5bf8af0e6c7e01e1004b54dd3f0a983f
exarkun@boson:~/Scratch/Run/demo$

This one's self signed, since I don't have a VeriSign certificate lying around to sign it with... Anyway, now I'm set for HTTPS:

exarkun@boson:~/Scratch/Run/demo$ axiomatic -d my.axiom start -n
2005/11/11 02:08 EST [-] Log opened.
2005/11/11 02:08 EST [-] twistd SVN-Trunk (/usr/bin/python 2.4.2) starting up
2005/11/11 02:08 EST [-] reactor class: twisted.internet.selectreactor.SelectReactor
2005/11/11 02:08 EST [-] xmantissa.website.AxiomSite starting on 8888
2005/11/11 02:08 EST [-] Starting factory <xmantissa.website.AxiomSite instance at 0xb7616c6c>
2005/11/11 02:08 EST [-] xmantissa.website.AxiomSite starting on 8889

So now you know how to alter HTTP port configuration for a Mantissa server (any Mantissa server) from the command line. I know I promised something about static content in the subject, but I've already gone on longer than I intended. I'll cover configuring static content tomorrow.

No comments:

Post a Comment