Alex
Alex

Reputation: 44719

Using WebPy as a static HTTP content server

How is it possible to tune up WebPy to use it to serve static content for several websites?

I run two websites on one IP using web.subdomain_application for name-based virtual hosting. The implied solution for hosting static content is to create a static/ directory in the directory containing HTTP server script and put all static files from both websited there.

However even if I create sub-directories site1/ and site2/ inside static/ to organize my resources, it would be possible to request Site1's resources on, say, http://site2.com/static/site1/foo.css. It seems natural to me to restrict such cross-site access to resources.

How to serve static stuff for two sites separately on WebPy?

Upvotes: 3

Views: 1088

Answers (1)

Luke McCarthy
Luke McCarthy

Reputation: 919

I prefer to use nginx to serve static content, e.g.:

location ~ ^/(static(/.*)?)$ {
    alias /srv/http/$1;
}

location / {
    include /etc/nginx/conf/uwsgi_params;
    uwsgi_pass unix:/tmp/my_webapp.sock;
}

Upvotes: 1

Related Questions