Publish folder using Apache
Following guide allows you to pick a folder on server and publish it for end-users using Apache web server. The web site is styled so it conforms to the Bohemia Market and Historian branding and a link to this website is placed into Historian menu.
Please note, that this document does not cover configuration of particular folders (e.g. mounting NFS shares, etc.)
Preparation
- The folder we are going to publish needs to exist, or needs to be created. Let's suppose it's folder /var/www/pa-backup which already exists.
- Then we need folder with styling data. Please download the data from here or you may find it inside every Historian since version 2.0.3 (usually under path /var/www/poweranalyzer/assets/index-styles.tgz). After downloading, please extract this archive to the web server machine (in our example, the path is /var/www
sudo tar -xzvf index-styles.tgz -C /var/www
We also need to set these file to be readable by all
sudo chmod -R uog+r /var/www/index-styles
Apache configuration
Now, we need to create an Apache configuration file for our new website, that will provide the web access to previously mentioned folder. The configuration follows, however there are few points which should be customized per-deployment.
- port number (8072 in our example)
- path to the folder being published (/var/www/pa-backup in our example)
- path to the styling folder (extracted in previous step, /var/www/index-styles in our example)
Change the required information and save the configuration under /etc/apache2/sites-available/003-dirlist.conf (naming of the website configuration file is up to your decision).
# Web site IP binding & port, don't forget to include the port number also inside ports.conf file <VirtualHost *:8072> # Where data folder resides DocumentRoot /var/www/pa-backup # Include alias to allow custom styling Alias /styles /var/www/index-styles # Where data folder resides <Directory /var/www/pa-backup> # We need indexes, the rest is optional Options Indexes FollowSymLinks MultiViews AllowOverride All # Styling configuration IndexOptions FancyIndexing IconsAreLinks SuppressDescription FoldersFirst HTMLTable IndexStyleSheet /styles/index.css DefaultIcon /styles/icons/icon_file.png AddIcon /styles/icons/icon_parent.png .. AddIcon /styles/icons/icon_folder.png ^^DIRECTORY^^ AddIcon /styles/icons/icon_file.png .xls .xlsx .sh .exe .conf AddIcon /styles/icons/icon_text.png .txt .doc .docx .pdf README AddIcon /styles/icons/icon_image.png .png .jpg .bmp .jpeg .mp4 AddIcon /styles/icons/icon_archive.png .tgz .zip .tar .tar.gz .gzip .bzip2 </Directory> </VirtualHost>
Please note that if you're using Apache v2.4 and newer, you must replace line
AllowOverride All
with
Require all granted
You also need to add new port into Apache listening configuration, which is usually under /etc/apache2/ports.conf file.
Listen 8072
Afterwards you may enable the site using command
sudo a2ensite 003-dirlist sudo service apache2 reload
Now you should be able to see the directory listing inside your browser (under url http://192.168.1.91:8072 where 192.168.1.91 is the IP address of the destination machine and 8072 is the port configured above).
Historian configuration
If you would like to include a link to the new website into Historian menu, you need to edit Historian configuration in order to do so. The configuration is explained in the detail on Server App Configuration page, however simply said, you need to edit the instance.xml file (usually stored under /var/www/poweranalyzer/App_Data/) and insert following element inside the relatedLinks section.
<relatedLinks> <relatedLink name="Backups" defaultUrl="http://192.168.1.91:8072" /></relatedLinks>
Please note, that:
- the relatedLinks section might already be present inside the configuration and might contain other relatedLink elements.
- Content of the attribute name is whatever you like to be shown to the user in place of a new link. The attribute might be localized (see complete configuration explanation for more details)
- Attribute defaultUrl contains complete url to the folder as configured in the previous step. If the Historian is placed inside multiple networks, you may need to configure multiple urls in order to server correct links for users coming from these networks (see complete configuration explanation for more details)
Once you change the configuration file, you need to restart the Historian app, which can be done for example using command:
sudo service apache2 restart
Now you should see the new link inside Historian (both on the login page and inside the top menu)
Alternative Subfolder Configuration
Sometimes it may be needed to configure published folder not as a separate VirtualHost (with different port binding), but as a folder under other VirtualHost. In this case only subfolder with data and subfolder with styling are mapped. Following code should be pasted inside existing VirtualHost configuration.
Alias /downloads /var/www/pa-backup Alias /downloads_styles /var/www/index-styles # Include alias to allow custom styling # Where data folder resides <Directory /var/www/pa-backup> # We need indexes, the rest is optional Options Indexes FollowSymLinks MultiViews AllowOverride All # Styling configuration IndexOptions FancyIndexing IconsAreLinks SuppressDescription FoldersFirst HTMLTable IndexStyleSheet /downloads_styles/index.css DefaultIcon /styles/icons/icon_file.png AddIcon /downloads_styles/icons/icon_parent.png .. AddIcon /downloads_styles/icons/icon_folder.png ^^DIRECTORY^^ AddIcon /downloads_styles/icons/icon_file.png .xls .xlsx .sh .exe .conf AddIcon /downloads_styles/icons/icon_text.png .txt .doc .pdf .docx README AddIcon /downloads_styles/icons/icon_image.png .png .jpg .bmp .jpeg .mp4 AddIcon /downloads_styles/icons/icon_archive.png .tgz .zip .tar .tar.gz .gzip .bzip2 </Directory>