-
Notifications
You must be signed in to change notification settings - Fork 589
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
vHosts Package #369
Changes from 4 commits
1a6830d
344400c
41f8476
1177f29
c66d3aa
c49f50c
5249fce
283f83a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Created by: Steve Thames <sthames42@gmail.com> | ||
# $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/ | ||
# ------------------------------------------------------------------------------ | ||
# 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. | ||
#******************************************************************************* | ||
|
||
PORTNAME= pfSense-pkg-vHosts | ||
PORTVERSION= 1.0.0 | ||
#PORTREVISION= 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented out line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of keeping the line in the file is that, while there is no need for a revision now, there may be in the future. Setting PORTREVISION=0 produces a version string of "1.0.0_0" which is not appropriate. This simply makes it easier to add a revision number without having to try and remember PORTREVISION is the variable to set. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's more, there is commented out code all through the pfSense source code. What is your objection to this? |
||
CATEGORIES= www | ||
MASTER_SITES= # empty | ||
DISTFILES= # empty | ||
EXTRACT_ONLY= # empty | ||
|
||
MAINTAINER= sthames42@gmail.com | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line can be removed, next line will create /pkg subdirectory since ${MKDIR} uses -p parameter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but the development that comes behind me will probably not know that. I didn't. So what is the harm in having both lines? |
||
${MKDIR} ${STAGEDIR}${PREFIX}/pkg/shortcuts | ||
${MKDIR} ${STAGEDIR}${PREFIX}/www/packages | ||
${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/packages/vhosts.php ${STAGEDIR}${PREFIX}/www/packages | ||
${INSTALL_DATA} ${FILESDIR}${PREFIX}/www/packages/vhosts_certs.php ${STAGEDIR}${PREFIX}/www/packages | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO these files should be installed in www/ instead of www/packages There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A number of packages store their files in www/packages. Since there is no documentation on the structure of the package environment, I used pfSense-pkg-Cron as my example. I would be happy to make this change later but now the application is working and I hesitate to change it. Can we wait until the package is accepted into the repository so at least it can be installed from the UI instead of manually from the command line? |
||
${INSTALL_DATA} ${FILESDIR}${DATADIR}/info.xml ${STAGEDIR}${DATADIR} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using more than 80 columns, use a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The advent of 80 column lines in code is a holdover of punch cards which were how programs were written up through the 1970's. When cards gave way to monitors, the early monitors were limited to 80 column displays without scrolling. |
||
@${REINPLACE_CMD} -i '' -e "s|%%PKGVERSION%%|${PKGVERSION}|" ${STAGEDIR}${DATADIR}/info.xml | ||
|
||
.include <bsd.port.mk> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# vHosts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?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'][] = "packages/vhosts.php*"; | ||
|
||
?> |
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} |
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} |
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'; | ||
?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makefile doesn't need to have all this license text, usually we keep them as clean as FreeBSD's ones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to be difficult but there is nothing in the style guide about makefiles.