0

I have no problems with jac in my flask application on my local CentOS 7 dev stack, but I can't deploy it to an AWS EB instance: the browser GET request doesn't get any response back.

The AWS EB /var/log/httpd/access_log just repeats this line about one hundred times:

127.0.0.1 (-) - - [12/Apr/2016:19:54:11 +0000] "GET / HTTP/1.1" 301 243 "-" "Python-urllib/2.7"

and ath the end:

xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx) - - [12/Apr/2016:19:55:35 +0000] "GET / HTTP/1.1" 301 247 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"

So on github jac repository there's a requirement.txt that is the following:

Jinja2
beautifulsoup4==4.3.2
rjsmin==1.0.10
ordereddict==1.1
six==1.9.0

but I didn't have to add anything since all the above lines are yet included in the requirements.txt file that I got from pip freeze.

I thought that the problem could be the lack of less library, since I have some css to compress, so I added the following to .ebextensions:

commands:
01-install-nodejs-npm:
    command: yum install -y --enablerepo=epel nodejs npm
02-install-less:
    command: npm install -g less

but that didn't resolve the issue.

I don't think there's something wrong with the code, since it works on the dev environment, but just to be sure, the following lines are in flaskApp init.py:

app.config['COMPRESSOR_DEBUG'] = app.config.get('DEBUG')
app.config['COMPRESSOR_OUTPUT_DIR'] = './flaskApp/static/mydomain-dev'
app.config['COMPRESSOR_STATIC_PREFIX'] = '/static/mydomain-dev'
jac = JAC(app)

env = jinja2.Environment(extensions=[CompressorExtension])
env.compressor_output_dir = './flaskApp/static/mydomain-dev'
env.compressor_static_prefix = '/static/mydomain-dev'
#env.compressor_source_dirs = './flaskApp/staticLib/'

I'm stuck at this point.

The only difference between CentOS venv app and AWS app is that, since the app uses flask_sslify, then every request on AWS is redirect to https (not in CentOS since flask_sslify deosn't redirect if app.debug = True).

Any idea please?

Marco Evasi
  • 441
  • 2
  • 14

1 Answers1

0

you are doing a configuration for flask and one for jinja (when used standalone). Remove those lines:

env = jinja2.Environment(extensions=[CompressorExtension])
env.compressor_output_dir = './flaskApp/static/mydomain-dev'
env.compressor_static_prefix = '/static/mydomain-dev'

And let JAC(app) configure it. But, JAC won't emit any 301 because it does not know any routes and stuff (I would need to check the code because I don't check it for a while). Where to is that page redirecting you?

Jayson Reis
  • 708
  • 5
  • 14
  • Jayson thanks for answering, in the meanwhile I've been deploying different attempts to AWS EB in order to make it work: I removed the lines you suggested, and then I tried to remove flask_sslify and I used also a plain /static/ path instead of my /flaskApp/static, but I couldn't make it work. – Marco Evasi Apr 20 '16 at 21:03
  • I actually don't know where the 301 redirects to. How can I check it out? – Marco Evasi Apr 20 '16 at 21:04
  • @marcoe it is hard to say, add more logging to your app to check where it is going. Or check to where the redirect is pointing maybe you can track the source. Isn't it redirecting the user to authenticate? – Jayson Reis Apr 21 '16 at 09:33
  • No, everything happens just loading the home page that doesn't require authentication. I suspect the issue is somehow related to the the AWS load balancer and/or HTTPS. And those last two things are correlated somehow, since it proved to be impossible to deploy an app with https redirects on a AWS single istance and I had, in order to activate HTTPS, to create a load balancer (see [link](http://stackoverflow.com/questions/34816885/elasticbeanstalk-configuring-https-on-single-instance-of-python-null-values-are). – Marco Evasi Apr 21 '16 at 12:56
  • So just to test if the issue is about load balancer and/or HTTPS I was trying to deploy the same app with Flask_sslify commented but, please don't ask me why, the AWS deploy kept on failing on both single istance or load balanced istances, and I really can't imagine what's the problem with AWS EB with that. So, after having spent on this matter really much more time than what I had, I'm stuck with no clue and for the moment I'm actually searching other alternatives. – Marco Evasi Apr 21 '16 at 13:00
  • That's a pity because this of yours really is a great piece of software. – Marco Evasi Apr 21 '16 at 13:01