Frappe-Manager icon indicating copy to clipboard operation
Frappe-Manager copied to clipboard

How to make the site accessible to the external networks?

Open NelsonGahima opened this issue 1 year ago • 9 comments

Description How to make a site accessible to the external networks?

Use Case I want to make my site called "site.localhost" installed on a remote linux server accessible to the external networks via my server's public IP address

Expected Behavior to be able to access my site outside the server's network by using <server_ip>:<port_number> format

Current Behavior (if applicable) i only access my site on my server by browsing http://site.localhost

NelsonGahima avatar Nov 24 '24 02:11 NelsonGahima

Hello NelsonGahima,

What you need is a reverse proxy. You can setup nginx for this purpose.

regards.

victorarocha avatar Jan 30 '25 00:01 victorarocha

Thank you @victorarocha It worked

NelsonGahima avatar Jan 30 '25 17:01 NelsonGahima

@NelsonGahima Can you explain what you changed?

meichthys avatar Sep 12 '25 17:09 meichthys

I set up an Nginx reverse proxy to make the container site's IP address (for example: 10.1.0.3:80) accessible via the host IP.

Here is how my Ngnix config looks:

server {
    listen <host_port>;

    server_name <host_IP>;

    location / {
        proxy_pass http://10.1.0.3:80;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

My site is now accessible through <host_IP>:<host_port>

I hope this is clear.

Thank you

NelsonGahima avatar Sep 12 '25 20:09 NelsonGahima

Thanks for following up so quickly.

meichthys avatar Sep 12 '25 20:09 meichthys

It is my pleasure.

NelsonGahima avatar Sep 12 '25 20:09 NelsonGahima

I have found a different solution that I have tested on WSL:

  1. Find the file \\wsl.localhost\Ubuntu\home\<username>\frappe\sites\<bench_name.localhost>\docker-compose.yml and open it in a text editor.
  2. Find the nginxsection:
nginx:
    image: ghcr.io/rtcamp/frappe-manager-nginx:v0.16.1
    container_name: fm__<bench_name>_localhost__nginx
    user: 1000:1000
    environment:
      SITENAME: <bench-name>.localhost
      VIRTUAL_HOST: <bench-name>.localhost
      VIRTUAL_PORT: 80
      HSTS: off
    volumes:
    - ./workspace:/workspace
    - ./configs/nginx/conf:/etc/nginx
    - ./configs/nginx/logs:/var/log/nginx
    - ./configs/nginx/cache:/var/cache/nginx
    - ./configs/nginx/run:/var/run
    - ./configs/nginx/html:/usr/share/nginx/html
    expose:
    - 80
    networks:
      site-network:
        aliases:
        - <bench-name>.localhost
      global-frontend-network: 
  1. Change VIRTUAL_HOST to include the host IP or address:
VIRTUAL_HOST: <bench-name>.localhost, 192.168.1.10
  1. After that, run fm stop <bench-name> then fm start <bench-name>

Hamza5 avatar Oct 27 '25 14:10 Hamza5

@Hamza5 Thanks! Do you know if this is a permament change for the life of the site, or will the changes be overwritted by any kind of fm commands likefm update?

meichthys avatar Oct 27 '25 15:10 meichthys

@Hamza5 Thanks! Do you know if this is a permament change for the life of the site, or will the changes be overwritted by any kind of fm commands likefm update?

You are welcome.

Unfortunately, I have no idea because I didn't test that case. I made the site accessible to the network, ran fm shell to get into the bench and install my custom app, then exited the shell and ran fm restart to finalize the app installation (I was getting errors before the restart). This process didn't affect the modified docker-compose.yml file, but I am not sure if this will be the case with other fm commands.

Hamza5 avatar Oct 27 '25 17:10 Hamza5