learninglocker icon indicating copy to clipboard operation
learninglocker copied to clipboard

nginx proxy configuration (failover )

Open rahmatellahmohammed opened this issue 6 years ago • 0 comments

hello all,

I have configured well learning locker (on ubuntu 18.04, but i have a problem with nginx proxy, without all works fine but to assure availability i will put it in front off 2 LRS (web servers) this is my configuration:

                                                         Ngins Failover
                                                                     |
                                                LRSapp1----------- LRSapp2                                                                                                                                    
                                                                     |
                                                                     | 
                                                                  Redis
                                                                     |
                                                    Replicaset Mongo (SSL)
                                                   

when i want to access to learninglocker using LRSapp1 or LRSapp2 all work fine, but whith NGINXfailover not.

i get all with nginxfailover but when i try to access to nginxfailover/data/xAPI it redirect me to /home

Nginx failover configuration

`upstream xx.yy.com { server 172.16.0.9:3000 fail_timeout=5s max_fails=3; server 172.16.0.10:3000 backup; } upstream xx.yy.com/api { server 172.16.0.9:8080 fail_timeout=5s max_fails=3; server 172.16.0.10:8080 backup; } upstream xx.yy.com/data/xAPI { server 172.16.0.9:8081 fail_timeout=5s max_fails=3; server 172.16.0.10:8081 backup; }

server {

server_name xx.yy.com Public IP ;

 #xAPI endpoints

location ~* ^/data/xAPI(.*)$ { proxy_pass http://xx.yy.com/data/xAPI$1$is_args$args; }

location /api { rewrite /api / break; proxy_redirect off; #include proxy_params; proxy_pass http://xx.yy.com/api; }

location ~* ^/api(.*)$ { proxy_pass http://xx.yy.com/api$1$is_args$args; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; }

        # all other traffic directed to statics or Node server

location / { try_files $uri @node_server; }

location @node_server {

#include proxy_params; proxy_pass http://xx.yy.com; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; }

  # Load configuration files for the default server block.

error_page 404 /404.html; location = /40x.html { root /usr/share/nginx/html; }

error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }

   # We don't need .ht files with nginx.

location ~ /.ht { deny all; }

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/xx.yy.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/xx.yy.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

} server { if ($host = xx.yy.com) { return 301 https://$host$request_uri; } # managed by Certbot

listen 80;

server_name xx.yy.com @IP (public); return 404; # managed by Certbot

}

With this configuration when i try to access to xx.yy.com/data/xAPI it forward me to /home,

I don't know why ! any help ? `

rahmatellahmohammed avatar Jan 07 '20 15:01 rahmatellahmohammed