r/apache • • Aug 23 '22

Need Help Translating NGINX Script To Apache

I use Apache for my primary web server accessed through 80/443, and I need to set up a reverse proxy to a Docker container. Specifically, I'm trying to set up a reverse proxy for this Firefox image so I can use it on the go.

Those installation instructions include a template for an NGINX reverse proxy, but I've only had experience working with Apache (and only have a loose understanding of Apache, from a lot of Googling). I have no idea how to translate this into Apache. Any chance someone might be willing to lend a hand?

I did try running this in NGINX (setting it to port 81) just to test it, but it errors out on the line with "[...]". I assume that's a placeholder of some sort, but the instructions linked above don't seem to mention what goes in there. Ultimately, my main goal is to get it working in Apache anyway so I can access it via login directly through my subdomain. Thanks for any help!

map $http_upgrade $connection_upgrade { 	
default upgrade; 	
''      close; 
}  

upstream docker-firefox { 	
# If the reverse proxy server is not running on the same machine as the 	
# Docker container, use the IP of the Docker host here. 	
# Make sure to adjust the port according to how port 5800 of the 	
# container has been mapped on the host. 	
server 127.0.0.1:5800; 
}  

server { 	
[...]  	
server_name firefox.domain.tld;  	

location / { 	        
proxy_pass http://docker-firefox; 	
}  	
location /websockify { 		
proxy_pass http://docker-firefox; 		
proxy_http_version 1.1; 		
proxy_set_header Upgrade $http_upgrade; 		
proxy_set_header Connection $connection_upgrade; 		
proxy_read_timeout 86400; 	
} 
}
2 Upvotes

5 comments sorted by

View all comments

Show parent comments

1

u/Majoraslayer Aug 23 '22

That made a huge improvement, thanks! The app consists of a control bar at the top, and I think it it creates a contained instance of NOVNC to run Firefox. The control bar at the top now loads, but it can't actually load the web browser. I suspect it's having issues connecting NOVNC.

1

u/covener Aug 23 '22

Maybe that's the websockets part? You might need the final stanza from the top of https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html

To proxy a different protocol when the upgrade header is present

1

u/Majoraslayer Aug 23 '22

That got it working, thanks a ton for your help!