How to make the site accessible to the external networks?
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
Hello NelsonGahima,
What you need is a reverse proxy. You can setup nginx for this purpose.
regards.
Thank you @victorarocha It worked
@NelsonGahima Can you explain what you changed?
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
Thanks for following up so quickly.
It is my pleasure.
I have found a different solution that I have tested on WSL:
- Find the file
\\wsl.localhost\Ubuntu\home\<username>\frappe\sites\<bench_name.localhost>\docker-compose.ymland open it in a text editor. - 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:
- Change
VIRTUAL_HOSTto include the host IP or address:
VIRTUAL_HOST: <bench-name>.localhost, 192.168.1.10
- After that, run
fm stop <bench-name>thenfm start <bench-name>
@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?
@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
fmcommands 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.