Do you have HTTPS configured for Elastic Beanstalk, per the docs at 
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https.html ?

If so, you’ll need to add a setting to ensure the generated routes start with 
https.

There are a couple of ways to do this.  The first option is to add the 
following to your production.ini file (for example)…

wsgi.url_scheme = https

The other option is to add a tween to auto-detect if there’s an HTTPS 
reverse-proxy fronting your WSGI server based on HTTP_X_FORWARDED_PROTO.  
Here’s an example of that tween…

https://github.com/eucalyptus/eucaconsole/blob/master/eucaconsole/tweens.py#L45-L51

HTH,
Kamal


From: Andrew Burnett
Sent: Friday, November 3, 2017 1:08 PM
To: pylons-discuss
Subject: Re: [pylons-discuss] Static Files on Elastic Beanstalk

Can you elaborate or point toward some lit that will help? I'm unfamiliar with 
how to set these, especially when running on AWS with Elastic Beanstalk. 

Thanks,
Andrew

On Friday, November 3, 2017 at 12:45:34 PM UTC-7, Michael Merickel wrote:
I would guess that you need to provide a more specific path to the files... I 
have no idea what the CWD is for that yaml file and whether `static/` is 
enough... I would guess that it needs to be something like `myapp/static/` at 
the very least to point to a location on disk relative to the root of your 
source tree.

Also any time you think the fix is to try request.static_path instead of 
request.static_url or request.route_path versus request.route_url etc it is 
*always* a misconfiguration of the WSGI environ such that it doesn't properly 
know where the app is being served from. This means either:

1) incorrect port
2) incorrect domain
3) incorrect protocol (http vs https)
4) incorrect path prefix if mounting your app somewhere that is not the root of 
a domain

The way to solve these issues is always with some understanding of WSGI server 
settings, reverse proxy settings (or aws load balancer), and WSGI environ keys. 
Usually this involves X-Forwarded-Proto and Host headers from the proxy and 
environ['SCRIPT_NAME'] + environ['PATH_INFO'] in the environ.

- Michael

On Fri, Nov 3, 2017 at 2:28 PM, Andrew Burnett <[email protected]> wrote:
I will try this and let you know. I've been down this route with `static_url` 
instead of `static_path`. Does that make a difference? The issue is in the 
server returning 404 Not Found errors when attempting to serve my static assets.

On Thursday, November 2, 2017 at 12:28:32 PM UTC-7, Kamal Gill wrote:
Try request.static_path(…)

e.g. <link rel="stylesheet" 
href="${request.static_path('app:static/css/settings/globals.css')}"/>

HTH,
Kamal


On Nov 1, 2017, at 4:03 PM, Andrew Burnett <[email protected]> wrote:

I'm trying to serve some static css, png's, etc. from my Pyramid app that's 
hosted on Elastic Beanstalk. It works fine on my local machine but when I try 
to run on EB, neither the CSS nor the images are found. Here's the relevant 
code:

>From .ebextensions:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: pyramid.wsgi
  aws:elasticbeanstalk:application:
    Application Healthcheck URL: /health
  aws:elasticbeanstalk:container:python:staticfiles:
    "/static/": "static/"

>From home.make

    <link rel="stylesheet" 
href="${request.static_url('app:static/css/settings/globals.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/settings/colors.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/objects/containers.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/base/base.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/components/articles.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/components/divs.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/components/footers.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/components/headers.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/components/img.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/components/links.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/components/lists.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/components/paragraphs.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/components/sections.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/components/small.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/state/links.css')}"/>
    <link rel="stylesheet" 
href="${request.static_url('app:static/css/utilities/utilities.css')}"/>

>From static_config.py

from pyramid.security import NO_PERMISSION_REQUIRED

### INCLUDEME

def includeme(config):
    """Configure static endpoints.
    """
    config.add_static_view(name='static',\
                           path='app:static')

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/b9be3daf-93cf-49c9-9ffd-f67d43e8289d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/e377d97f-2c99-4b79-87b6-f78c51f25ef3%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/7978ce21-e2e4-424e-ad50-bad2abe2aa3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/59fcd4c0.aa119d0a.c0d18.2f3a%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to