Giter Club home page Giter Club logo

Comments (9)

tawan avatar tawan commented on June 20, 2024

Hi @Onumis ,

Thanks for reporting this problem. Moving the middleware up is probably acceptable. I will incorporate this in the next release.

from active-elastic-job.

AlexanderUlitin avatar AlexanderUlitin commented on June 20, 2024

@tawan experienced the same issue, after I enabled force_ssl on my env. @Onumis your solution works for me too, thanks.
@tawan many thanks for doing this gem, hope you will able to fix this issue soon.

from active-elastic-job.

tawan avatar tawan commented on June 20, 2024

@Onumis @AlexanderUlitin Hi, Version 1.4.4 supports SSL and is released.

from active-elastic-job.

AlexanderUlitin avatar AlexanderUlitin commented on June 20, 2024

@tawan many thanks to you for doing this. I'll test it over this week on staging env and will report here.

from active-elastic-job.

nunosilva800 avatar nunosilva800 commented on June 20, 2024

Awesome!

from active-elastic-job.

AlexanderUlitin avatar AlexanderUlitin commented on June 20, 2024

It works great on real instances. Thanks.

from active-elastic-job.

holman avatar holman commented on June 20, 2024

Has anyone run into this recently? I'm getting these http => https redirects again on 2.0.1.

from active-elastic-job.

joselo avatar joselo commented on June 20, 2024

I'm still getting this error 301, I'm using the version ~> 2.0 and I the version of the sqs is aws-sqsd/2.3

It could be caused by my web tier configuration for nginx?? also I have my production file with config.force_ssl = true

          # Redirect to HTTPS                                                                                       
          if ($http_x_forwarded_proto != "https") {                                                                 
            rewrite ^(.*)$ https://$host$request_uri permanent;                                                     
          }

I really needs to redirect all traffic to htts

Any idea to solve this? :(

from active-elastic-job.

joselo avatar joselo commented on June 20, 2024

I solved the problem, I think basically SQS works over http not https so if you rewrite your request to https, sqs doesn't work, here is my .ebextension for nginx.

I also had to change the path of the worker, so that it can send the request to /active_job. (You can change the name of the path, don't forget to change in the nginx file too.

screenshot from 2018-02-26 18-31-01

I tested and it works

files:
   "/opt/elasticbeanstalk/support/conf/webapp_healthd.conf":
     owner: root
     group: root
     mode: "000644"
     content: |
       client_max_body_size 10M;

       upstream my_app {
         server unix:///var/run/puma/my_app.sock;
       }

       map $uri $preferred_proto {
         default "https";
         ~^/(packs|public)/ "none";
         ~^/active_job "http";
         ~^/health "http";
       }

       log_format healthd '$msec"$uri"'
                       '$status"$request_time"$upstream_response_time"'
                       '$http_x_forwarded_for';

       server {

         sendfile on;

         tcp_nopush on;
         tcp_nodelay off;

         gzip on;
         gzip_http_version 1.0;
         gzip_proxied any;
         gzip_min_length 500;
         gzip_disable "MSIE [1-6]\.";
         gzip_types text/plain text/xml text/css
                   text/comma-separated-values
                   text/javascript application/x-javascript
                   application/atom+xml;


         listen 80;
         server_name _ localhost;

         root /var/app/current/public;

         error_page 405 = /active_job;

         if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
           set $year $1;
           set $month $2;
           set $day $3;
           set $hour $4;
         }

         access_log  /var/log/nginx/access.log  main;
         access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;

         try_files $uri/index.html $uri.html $uri @app;


         if ($preferred_proto = "http") {
           set $http_x_forwarded_proto $preferred_proto;
         }

         if ($preferred_proto = "none") {
           set $preferred_proto $http_x_forwarded_proto;
         }

         if ($preferred_proto != $http_x_forwarded_proto) {
           rewrite ^(.*) $preferred_proto://$host$request_uri redirect;
         }


         # App always use https
         location @app  {
           proxy_http_version 1.1;
           proxy_set_header Connection "";
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-Proto https;
           proxy_set_header Host $host;

           proxy_pass http://my_app;
         }


         # WS support always use https
         location /cable {
           proxy_http_version 1.1;
           proxy_set_header Upgrade "websocket";
           proxy_set_header Connection "Upgrade";
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-Proto https;
           proxy_set_header Host $host;

           proxy_pass http://my_app;
         }


         # Elastic active jobs don't use https
         location /active_job {
           proxy_http_version 1.1;
           proxy_set_header Connection "";
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header Host $host;

           # note the trailing slash here, it matters!
           proxy_pass http://my_app/;
         }


         # Change packs for assets if you are using native compile assets for rails app
         location /packs {
           alias /var/app/current/public/packs;
           gzip_static on;
           gzip on;
           expires max;
           add_header Cache-Control public;
         }


         location /public {
           alias /var/app/current/public;
           gzip_static on;
           gzip on;
           expires max;
           add_header Cache-Control public;
         }
       }

container_commands:
  99_restart_nginx:
    command: "service nginx restart || service nginx start"

from active-elastic-job.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.