OPNsense Forum

Archive => 18.7 Legacy Series => Topic started by: coldtech on October 11, 2018, 02:38:49 pm

Title: Host small webserver on opnSense / add lighttpd vhost?
Post by: coldtech on October 11, 2018, 02:38:49 pm
Hey everyone,

I just recently started setting up an opnSense installation and am in the process of migrating my openwrt settings. One of the things I did on my openwrt router was having lighttpd installed which just hosts a single webpage on port 83 - which I forwarded locally in the firewall so that users accessing my public IP address on port 80 will be shown this single page.

Is it possible to do this with opnsense using vhosts (or any other method)? I'm assuming yes, since opnsense already runs lighttpd for the GUI, but because of that the existing lighttpd config is rather intimidating. I just don't know the steps and where to start. So to summaroize what I would like to do:

- host a single webpage on the opnsense machine
- make it accessible from the outside
- all of that without making the management GUI accessible from the outside or mess up the management GUI in any way

Did anyone already do this? I don't want to set up up a separate machine just for this single page...

Any help would be appreciated!
Title: Re: Host small webserver on opnSense / add lighttpd vhost?
Post by: mimugmail on October 11, 2018, 03:00:06 pm
Did you try Nginx Plugin?
Title: Re: Host small webserver on opnSense / add lighttpd vhost?
Post by: fabian on October 11, 2018, 06:38:19 pm
In depends on your expectations. The nginx plugin offers static + PHP content directly from the FW but no Java EE, Ruby on Rails etc. and currently no official database support (OPNsense comes with sqlite).
Title: Re: Host small webserver on opnSense / add lighttpd vhost?
Post by: coldtech on October 11, 2018, 07:02:28 pm
Did you try Nginx Plugin?

Thanks, I will give that a try - much appreciated!
Title: Re: Host small webserver on opnSense / add lighttpd vhost?
Post by: coldtech on October 11, 2018, 10:48:12 pm
Did you try Nginx Plugin?

So I got it working in a way - at least the website is being displayed when accessing the firewall from the internal network (I chose port 83 for nginx).
But for the life of me I can not figure out how to forward external requests for port 80 to port 83 internally.

Here's what I did:
- changed the management GUI settings to only listen on the LAN interface
- created a NAT port forwarding roule on interface WAN, ptotocol TCP, source address any, source port any, destination address WAN, destination port 80, redirect to the opensense internal IP on port 83

...but it does not work this way. I had this running on openWRT before, so I'm not exactly new to the principles involved, but it seems that there's something I'm missing.

edit: everything was correct, but I needed to set NAT reflection: Enable - now it works