Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vHosts Package #369

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions www/pfSense-pkg-vHosts/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Created by: Steve Thames <[email protected]>
# $FreeBSD$
#*******************************************************************************
# vHosts package makefile.
# see: https://github.com/pfsense/FreeBSD-ports/blob/devel/Mk/bsd.port.mk
# and: https://www.freebsd.org/doc/en/books/porters-handbook/
#*******************************************************************************

PORTNAME= pfSense-pkg-vHosts
PORTVERSION= 1.0.0
PORTREVISION= 0
CATEGORIES= www
MASTER_SITES= # empty
DISTFILES= # empty
EXTRACT_ONLY= # empty

MAINTAINER= [email protected]
COMMENT= Web Server Package for pfSense

LICENSE= APACHE20

NO_BUILD= yes
NO_MTREE= yes

SUB_FILES= pkg-install pkg-deinstall
SUB_LIST= PORTNAME=${PORTNAME}

do-extract:
${MKDIR} ${WRKSRC}

do-install:
${MKDIR} ${STAGEDIR}/etc/inc/priv
${MKDIR} ${STAGEDIR}${PREFIX}/pkg/shortcuts
${MKDIR} ${STAGEDIR}${PREFIX}/www
${MKDIR} ${STAGEDIR}${DATADIR}
${INSTALL_DATA} ${FILESDIR}/etc/inc/priv/vhosts.inc ${STAGEDIR}/etc/inc/priv
${INSTALL_DATA} ${FILESDIR}${PREFIX}/pkg/vhosts.xml ${STAGEDIR}${PREFIX}/pkg
${INSTALL_DATA} ${FILESDIR}${PREFIX}/pkg/vhosts.inc ${STAGEDIR}${PREFIX}/pkg
${INSTALL_DATA} ${FILESDIR}${PREFIX}/pkg/shortcuts/vhosts.inc ${STAGEDIR}${PREFIX}/pkg/shortcuts
${INSTALL_DATA} ${FILESDIR}${PREFIX}/www/vhosts.php ${STAGEDIR}${PREFIX}/www
${INSTALL_DATA} ${FILESDIR}${PREFIX}/www/vhosts_certs.php ${STAGEDIR}${PREFIX}/www
${INSTALL_DATA} ${FILESDIR}${DATADIR}/info.xml ${STAGEDIR}${DATADIR}
@${REINPLACE_CMD} -i '' -e "s|%%PKGVERSION%%|${PKGVERSION}|" ${STAGEDIR}${DATADIR}/info.xml

.include <bsd.port.mk>
58 changes: 58 additions & 0 deletions www/pfSense-pkg-vHosts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# vHosts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add other files like this in root port directory. This information can be moved as a comment in the source code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this one has me baffled. README.md is not included in the build and only serves as a help page for someone that might want to have a look at some documentation. The help page facility for packages is broken which is why there is no help for many packages. In the future, I'm hoping to fix that and use this file to create the actual help page. In the meantime, what is the objection to putting this file in the root given it's not included in the build?


## Name/IP Based Virtual Host Web Server
---
A web server package to host HTML, Javascript, CSS, and PHP as Name or IP Based virtual hosts.
This is a full rewrite/port of the pre-2.3.0 vhosts package using the [nginx](https://wiki.nginx.org/)
web server installed with pfSense 2.3.0 and later versions.

This tool was ported to provide a simple way of returning a single page, for all requests, to a web server
that sits behind the router and requires maintenance. This is a very limited requirement and using
this package on the router for anything more robust than simple serving of pages is not recommended.

## Configuration

The vHosts server creates an instance of the nginx web server using a configuration file built from the
list of vHosts definitions. The Certificates list contains SSL/TLS certificates that may be bound to hosts
requiring secure connections.

### Hosts

* **Directory Name**
<br>Document root directory name in `/usr/local/vhosts`. The default documents are `index.html`,
`index.htm`, and `index.php`. If none exists, `index.php` is created to display the current PHP status.
<br><br>**Note:** Other than creation of the default `index.php`, the vHosts package does not manage any
of the files in a host root directory. Pages must be added and removed manually.

* **IP Address**
<br>Host IP address. Must be one of the IP addresses bound to the router.

* **Port**
<br>Port number for binding to the IP address.

* **Host Name(s)**
<br>Space separated list of Name-Based Host(s). Not required for an IP-Based host.

* **Secure Certificate**
<br>The certificate common name (CN) of the certificate selected to secure the host. Certificates must
be loaded to the Certificates list before they can be assigned to a host.

* **Custom Configuration**
<br>Additional configuration parameters to be included in the nginx configuration. Simple parameters are
recommended to prevent creating errors in the configuration.
<br><br>**Note:** If the vHosts service fails to start, configuration errors will be found in `/var/log/nginx/error.log`.
<br><br>Examples:
- `return 301 https://$host$request_uri;`
<br>Redirect the request to "https:".

- `rewrite ^.*$ /allpages.html last`
<br>Rewrite the URI to return a single page for all requests.

### Certificates

For secure hosts, the SSL/TLS certificate must be loaded into the certificates list before it can be
assigned to a host. Multiple hosts may be bound to a single certificate.

Certificates may be added or updated by dropping/pasting the Certificate and Certificate Key in X.509
PEM format or by loading the PKCS#12 file (.p12/.pfx) containing the key-pair.

36 changes: 36 additions & 0 deletions www/pfSense-pkg-vHosts/files/etc/inc/priv/vhosts.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/*******************************************************************************
* vHosts package privileges.
* ------------------------------------------------------------------------------
* Part of pfSense 2.3 and later (https://www.pfSense.org/).
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
*
* Inspired by vhosts package originally written by Mark Crane.
* Copyright (C) 2008 Mark J Crane
* Copyright (C) 2015 ESF, LLC
* Copyright (C) 2016 Softlife Consulting
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
global $priv_list;

$priv_list['page-services-vhosts'] = array();
$priv_list['page-services-vhosts']['name'] = "WebCfg - Services: vHosts package";
$priv_list['page-services-vhosts']['descr'] = "Allow access to vHosts package GUI";

$priv_list['page-services-vhosts']['match'] = array();
$priv_list['page-services-vhosts']['match'][] = "vhosts.php*";
$priv_list['page-services-vhosts']['match'][] = "vhosts_certs.php*";

?>
3 changes: 3 additions & 0 deletions www/pfSense-pkg-vHosts/files/pkg-deinstall.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

/usr/local/bin/php -f /etc/rc.packages %%PORTNAME%% ${2}
7 changes: 7 additions & 0 deletions www/pfSense-pkg-vHosts/files/pkg-install.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

if [ "${2}" != "POST-INSTALL" ]; then
exit 0
fi

/usr/local/bin/php -f /etc/rc.packages %%PORTNAME%% ${2}
30 changes: 30 additions & 0 deletions www/pfSense-pkg-vHosts/files/usr/local/pkg/shortcuts/vhosts.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*******************************************************************************
* vHosts package shortcuts.
* ------------------------------------------------------------------------------
* Part of pfSense 2.3 and later (https://www.pfSense.org/).
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
*
* Inspired by vhosts package originally written by Mark Crane.
* Copyright (C) 2008 Mark J Crane
* Copyright (C) 2015 ESF, LLC
* Copyright (C) 2016 Softlife Consulting
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
global $shortcuts;

$shortcuts['vhosts'] = array();
$shortcuts['vhosts']['service'] = 'vhostsd';
?>
Loading