How to reverse proxy to Open edX sites deployed with tutor from another server

i have deployed latest version (nutmeg) Open edX in production mode using tutor in one of my server. I want this url to be accessed from a different site.I have reverse proxied this site using nginx. But i am not getting access to Open edX when accessed from there.What to do

Hi @Aneesh_R_S, you can follow the instructions at Running Open edX behind a web proxy — Tutor documentation.

Hi TonyH,
Thank you for your response. I am little confused regarding writing proxy pass in nginx.
How can I access the openedx running port.

This is my Nginx file configuration after changing caddy port to 81.using the command

tutor config save --set ENABLE_WEB_PROXY=false --set CADDY_HTTP_PORT=81

server {

server_name mywebsite.com www.mywebsite.com;

location ^~ /imgs {
autoindex on;
alias /var/tmp;
}

location / {
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#
proxy_set_header Accept-Encoding “”;
proxy_pass http://127.0.0.1:81/;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
include fastcgi_params;
sub_filter_once off;
sub_filter_types text/html;
sub_filter ‘http://127.0.0.1:81’ ‘mywebsite’;

}

location = /50x.html {

root /var/www/nginx-default;

#}

}

Is this the correct way to access the tutor run openedex

Thanks and Regards

I haven’t actually used Tutor in a reverse proxy configuration, so I’m making some assumptions here. :slight_smile:

First, I’ll assume that you restarted Tutor to apply the new config.

The documentation states that:

You should set up a reverse proxy to localhost:CADDY_HTTP_PORT from the following hosts: LMS_HOST, PREVIEW_LMS_HOST, CMS_HOST,

Here is a basic reverse proxy config for Nginx with the above information. You would need to specify all of the subdomains that you use in your Open edX instance. At a minimum, I’m assuming you have the subdomain names of apps, studio, and preview. Because Tutor uses a name-based system and not IP-based, you must use the same values in the Nginx conf that specified during quickstart (saved in the Tutor conf.yml file).

server {
    listen 80;

    server_name  www.mywebsite.com studio.www.mywebsite.com preview.www.mywebsite.com apps.www.mywebsite.com;

    location / {
        proxy_pass http://localhost:81;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

You can test it using curl to verify that the reverse proxy returns a 200 or 300 HTTP code (not a 502).

curl --head http://www.mywebsite.com

curl should return something like this (but referencing nginx, not Caddy):

HTTP/2 200
content-language: en
content-type: text/html; charset=utf-8
server: Caddy
set-cookie: csrftoken=l9vGG8FRT. . .
set-cookie: sessionid=1|7ga7e46vxx . . . 
   Domain=www.mywebsite.com; 
   expires=Wed, 05 Oct 2022 13:03:32 GMT;
   HttpOnly; Max-Age=1209600; 
   Path=/; SameSite=None; Secure
  . . .
1 Like

thank you very much…It worked

1 Like