jazzband / django-embed-video

Django app for easy embedding YouTube and Vimeo videos and music from SoundCloud.

Home Page:http://django-embed-video.rtfd.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suddenly stopped working on AWS.

goromachine opened this issue · comments

commented

I've been using this package since more than a year without any problem and, without making any change to my code, it just stopped working on server, but still working on my local machine.

This is the created html by the tags and the video is real and actually public on youtube:

<iframe width="640" height="360" src="http://www.youtube.com/embed/yOcZmmg186Y?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>

I just updated to the last version to see if that was the problem but still not working on server. What can I do?

Does the AWS EC2 server have

  1. security group rules configured that allow outbound egress traffic to YouTube and
  2. access to the Internet either via elastic network interface that has a public IP address or a NAT gateway in the VPC?

I'd suspect a configuration change in the networking stack that prevents the server from getting the video information from the specific backend. On AWS it's pretty common to have a inbound load balancer (essentially a proxy) allowing client access to server but no NAT gateway or ENI allowing outbound access to Internet.

commented

I did not changed anything on the server either. I checked also and the outbound traffic rules are set with an All traffic Type:
image

About the second point, I really don't know how to check that but I create my environments using ElasticBeanstalk and I did not configure anything about the VPC.

I also have problems when creating a basic EB environment just to try this.

Check your server logs to see if there is an indication of any network error or similar problems on the application level.

You can also check if your instances have either a public Elastic IP address or if your VPC has a NAT gateway configured in the appropriate AWS region:

Make sure to change the region from Frankfurt or eu-central-1 to the region you are using.

Check the relevant AWS documentation:

Can't really help you much more than that if all the information we have is that the project doesn't work on specific AWS Elastic Beanstalk deployment and we don't have logs or more detailed information, sorry.

commented

I've seen the problem on the console now (sorry for my inexperience):

Mixed Content: The page at 'https://mydomain.com/myurl' was loaded over HTTPS, but requested an insecure resource 'http://www.youtube.com/embed/r6lU5mJJIeg?wmode=opaque'. This request has been blocked; the content must be served over HTTPS. 

But the url of the video added have https: https://www.youtube.com/watch?v=r6lU5mJJIeg .

My current block of code is:

{% video project.video as my_video %}
{% video my_video '640x360' %}
{% endvideo %}

And searching on the examples I've seen that I can add the is_secure=True to it. I supposed this makes the connection secure, but it did anything:

{% video project.video is_secure=True as my_video %}
{% video my_video '640x360' %}
{% endvideo %}

The resulting code is the same with the http video and not the https I set.
In local works because I have no SSL, but on the server now seems to be the problem.

This seems weird because youtube always works with https, so there is no reason to put the url without the security right?

Knowing the problem now, is there anyway of solving this for me?

Edit: New information -

Also the straight example in the docs to use always https:

{% video my_video query="rel=0&wmode=transparent" is_secure=True as my_video %}
    {{ my_video.url }} {# always with https #}
{% endvideo %}

Is showing me the url, not the video itself. But at least the URL is using https.

Edit: more information

Also the straight example in the docs to use always https:

{% video my_video query="rel=0&wmode=transparent" is_secure=True as my_video %}
    {{ my_video.url }} {# always with https #}
{% endvideo %}

Is showing me the url, not the video itself. But at least the URL is using https.

commented

On the embed_vide_tags.py I found that there is another way of adding it to the template:

Usage (shortcut):
    .. code-block:: html+django
        {% video URL [SIZE] [key1=value1, key2=value2...] %}

so in my case I did this:
{% video project.video '640x360' query="rel=0&wmode=transparent" is_secure=True %}

And worked fine. Now the url contains https and is showing as an embeded video.

BUT I'm not closing this issue because it seems to be a problem with the is_secure on the block template code and I did not fins anyway of making it work with the is_secure.
Maybe the title of the issue can be changed but as I'm not the owner of the project I don't know if it's the proper way of dong it. Something like: is_secure on block template code is not working it could be the correct title, and the problem with AWS just a collateral damage of it.

Have you configured the SECURE_PROXY_SSL_HEADER as per Django documentation so that your site (Django server) knows that it is being served over HTTPS and not HTTP? The load balancer probably strips the site URL, sets it into the HTTP headers and uses a local IP address or hostname for serving the site. The same applies for HTTP vs. HTTPS information which is contained in the headers and needs to be configured for Django to work correctly.

https://docs.djangoproject.com/en/3.1/topics/security/#ssl-https

commented

I did not, but I'll try it right now.
It's weird that in one way is working fine but on the other one do not.

@goromachine Any luck on this?

Is this issue still relevant? We haven't heard back in a while and I'm just checking if you are still facing the problem.