Unless you need to lock those files down with pyramid auth, I would isolate 
them away for Apache to serve.

I am very familiar with Dreamhost, and running fcgi stuff on it.  I keep 
some subversion/trac stuff on it - I really need to upgrade those to git!

I would avoid serving anything static on Dreamhost through Pyramid.  They 
have some throttling and process monitoring on their virtualization stack - 
and do not have a nice cleanup of old fcgi processes.  All your static 
assets are going to be competing for limited resources with the urls that 
can only be handled by the Pyramid app.

If you can map the apache subdir to the pyramid static folder, that would 
be ideal.  Another option is serving the static files as a separate 
subdomain, mapping the static dir to that domain on dreamhost, and using a 
toggle in your app to handle the url prefix for the assets (same domain on 
testing environment, subdomain on production).




On Saturday, March 23, 2024 at 4:08:55 PM UTC-4 Aaron Krister Johnson wrote:

> Hi all,
>
> I have a pyramid app on Dreamhost, and they are reverting from using 
> Ruby's passenger back to fcgi fro shared hosting accounts. The server runs 
> Apache, and I have control of .htaccess configuration.
>
> At the moment, I am able to serve static files by using 
> `config.add_static_view`, but it does not appear to be working for things 
> like videos hosted on site (.mp4) nor audio (.ogg).
>
> I thought to bypass `add_static_view` and have Apache serve static assets 
> itself, but it's brought no joy, since apparently, my setup doesn't allow 
> `Alias` directives, and the `RewriteCond` for files doesn't play well with 
> Pyramid's layout, with or without `add_static_view`. The basic site seems 
> to work better when I use Pyramid to serve, but like I said, video and 
> audio files are blocked somehow. How do I serve .mp4 and .ogg? Do I have to 
> get into declaring things iwth the `mimetypes` lib?
>
> Here's my .htaccess, for reference:
>
> $ cat .htaccess
> #Disables GZIP
> SetEnv no-gzip 1
>     
> #Turns off the expires headers for Apache
> <IfModule mod_expires.c>
>   ExpiresActive Off
> </IfModule>
>
> # DISABLE CACHING
> <IfModule mod_headers.c>
>   Header set Cache-Control "no-cache, no-store, must-revalidate"
>   Header set Pragma "no-cache"
>   Header set Expires 0
>   Header always set Content-Security-Policy "upgrade-insecure-requests;"
> </IfModule>
>
> Options +ExecCGI
> AddHandler fcgid-script .fcgi
> SetHandler fcgid-script
> RewriteEngine On
> RewriteBase /
> RewriteCond %{HTTPS} !=on
> RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]
>
> And here is my `dispatch.fcgi`:
>
> #!/home/untwelve_admin/untwelve.dreamhosters.com/bin/python3.12
>
> import sys
>
> from paste.deploy import loadapp
> from flup.server.fcgi_fork import WSGIServer
>
> sys.path.append("UnTwelveDotOrg")
>
> app = loadapp(
>     "config:/home/untwelve_admin/
> untwelve.dreamhosters.com/UnTwelveDotOrg/development.ini"
> )
>
> if __name__ == "__main__":
>     WSGIServer(app).run()
>
>
> Thanks for any insights you can provide!
>
> Best,
> Aaron
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/8fdecb11-6fec-446e-8eda-1f68b7969ff5n%40googlegroups.com.

Reply via email to