You don’t really need to. Moreover,
Is what’s going wrong.
Nginx is a fully-functioning reverse proxy on its own- why do you need Apache to proxy calls it? I’m going to bet that somewhere in the nginx-Apache configuration is where you’re hitting walls during setup.
In a typical, local site setup-
ERPNext
Python :: 8000
[something?.. I think maybe ‘local’ nginx?] :: 8080
Socketio :: 9000
Mariadb :: 3306/3307
[vague, possibly deprecated file transfer] :: 6768
Redis (caching) :: 11000,12000,13000
Since all of that is running locally amongst itself, you just connect to the python port (8000) via a web browser, and any other quick connections to you just kind of happen unseen in the background (primarily socketio port 9000 connections for file transfer).
Once you make it a live (web-hosted) site- whether just for local intranet or full, public access; basically when you configure your hostname- then the picture becomes:
ERPNext
nginx :: ports 80/443
^v^v^v^v
{everything else}
I’m not sure how you are configuring the whole… apache and nginx thing… but clearly, once you tell it to run on during the initial, browser-based setup, it’s turning nginx on for ‘live’ site mode, kicking everything behind nginx and rerouting port 8000, along with everything else not 80/443, through nginx :: 80.
You end up getting a 502 at this point because Apache is routing traffic from 80 (you) :: 8020 (nginx)… which, after being told to run in ‘live’-site mode, is now blocked. Try this- I’m not sure what you’re using apache for, but take it out of the equation for now.
Just… make it as simple and straight forward as possible just to get past the web-based initial setup. THEN, you can start poking, playing, and rewriting config files because you’ll have a baseline to go back to.
As I said in the first post, I recommend either setting up for local OR ‘live’ via command line (when the only port used is 22… or none if you are legit physically local) and then sticking to that setup through the initial web-based admin configuration. If you are wanting to set up for a ‘live’ site at an address- even for local intranet use and not public use- set up the hostname configurations/nginx setup/multi_tenant_mode PRIOR to accessing the web-based admin setup.
By the way- multi_tenant_mode is what allows you to set up non-standard ports like 8020; search for ‘multi_tenant_mode’ or ‘multi tenant’ on here for several guides.
The important bit, though-
‘local’-access based site :: like 4-5 ports, the main ones being 8000,9000
‘live’-access based site :: 80/443, with nginx serving as gateway/proxy to coordinate everything
IF you insist on configuring ‘live’-access via ‘local’-ports, you HAVE to make sure that the ‘live’-access ports are opened, configured, and redirecting properly in order to maintain a connection when the switch goes into effect. But again. configure access via cli-not the web browser. you’re just asking for issues doing it that way. and with the whole apache thing. Now you’re not just trying to change a tire while driving- you’re trying to do it with a ratchet turning a tire iron.
Check out:
https://frappe.io/docs/user/en/bench/guides/setup-multitenancy
https://frappe.io/docs/user/en/bench/guides/setup-production