we run a PVWS instance on NDAEXTWEB4 for the Web Dashboard
This is done with a native tomcat service (rather than a container) following the PVWS instructions, though it could be run as a container in the future.
Things to consider when updating Tomcat/PVWS:
- Tomcat installer from https://tomcat.apache.org/download-90.cgi installed in
C:\Program Files\Apache Software Foundation\Tomcat 9.0 pvws- we are using the latest nightly .war as of 01/11/24 - to update download this and place in the tomcatdir\webappsfolder and restart the service- jdk 21 from https://adoptium.net/en-GB/ installed in
C:\Program Files\Eclipse Adoptium\jdk-21.0.5.11-hotspot
- install tomcat as a windows service, using the defaults set by the wizard. Note the shutdown port to
-1, this disables it as per the security guidelines:
During the installer expand +Tomcat when it asks you which components to install, and tick the option which starts tomcat on startup.
- copy
pvws.warto thewebappsdirectory in the tomcat directory (usuallyC:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps) - in your
tomcat\bindirectory, we need to add theEPICS_CAvariables that specify the gateway address so PVWS knows where to look for PVs. this is done by runningTomcat9.exewith the//US(update server) flag ie:C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin>Tomcat9.exe //US ++Environment EPICS_CA_AUTO_ADDR_LIST=NO;EPICS_CA_ADDR_LIST=<ip>where ip is the gateway address. (more info on this command here) note, don't do this in powershell as it tries to interpret the arguments as separate commands. - create a
.pfxfile if you need a new certificate by using Windows'certificate manager -> wherever the cert is -> all tasks -> export
- no, do not export the private key
- "personal information exchange",
include all certificates in the certification path if possible: true, delete the private key if export is successful: false, export all extended properties: false, enable certificate privacy: false
- edit
server.xmlto contain these lines, removing the default connector:
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true"
maxParameterCount="1000" Server=" "
scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="file:///C:/PROGRA~1/APACHE~1/TOMCAT~1.0/dataweb.pfx" keystoreType="PKCS12" keystorePass="<keeper:.pfx keystore password for PVWS tomcat instance on NDAEXTWEB3>"
>
</Connector>this will start a https connector using the .pfx file generated from the certificate.
- go to
services.mscand hit restart on the tomcat service then navigate tohttps://<machine name>:7777/pvws- this should present the PVWS test page. - update the max message size to
131072as per "increasing maximum message size" of https://github.com/ornl-epics/pvws?tab=readme-ov-file#running-under-tomcat - this should be done inC:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\pvws\WEB-INF\web.xml - restart the service again
- if you want the web dashboard to permanently use this, update https://github.com/ISISComputingGroup/WebDashboard/blob/main/.env
- Add the following in
C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\web.xml(or equivalent path if you've updated tomcat):
<security-constraint>
<web-resource-collection>
<web-resource-name>restricted methods</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>OPTIONS</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
-
For access to the host, see the systems administration wiki.
-
Request a new certificate
-
Use OpenSSL to generate a CSR (for simplicity, do this on the host using Git Bash):
winpty openssl req -newkey rsa:2048 -keyout PRIVATEKEY.key -out MYCSR.csrThe answers to the questions it asks can be found by opening the old certificate. Store the passphrase you use to encrypt the private key somewhere safe (e.g. keeper) and the privte key in a sensible directory (e.g.
C:\certificates\yyyy-mm) -
Send the CSR to DI requesting a new certificate (use the group email account)
-
wait for an email back with a link to the signed certificate
-
-
Once we recieve the certificate back, generate a pfx/p12 file (for simplicity, do this on the host)
-
On the host, open the link sent by the certificate provider (
as Certificate (w/ chain), PEM encoded) and use it to download the certificate to a sensible directory (e.g.C:\certificates\yyyy-mm) -
Run OpenSSL in that directory using Git Bash to combine the certificate and private key:
winpty openssl pkcs12 -export -out new_cert_yy_mm.pfx -inkey key.key -passin pass:PASSWORD -in cert.cerWhere
key.keyis the private key created when you created your certificate signing request in step 2,PASSWORDis the passphrase used to generate that key, andcert.ceris the certificate you downloaded. When prompted enter the passphrase specified for the current certificate inC:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\server.xmland also stored in keeper.Note:
winptymay be required for openssl to function correctly on Windows.
-
-
Add
local serviceto the users that can read the file you have just generated like so: -
Open
server.xml(see above) to work out where the currentkeystoreFileis. Rename this by apending.oldor similar to make reverting this change easier -
rename the pfx file generated to match the name of the previous keystore file and place it in the same directory. The file extension may be
.p12rather than.pfx, they are interchangeable for this purpose. (If doing this using windows explorer, you may want to ensure that file extensions are visible). -
Go to
services.mscand restart the tomcat service (name startsAPACHE TOMCAT). -
In a web browser, navigate to
https://<machine name>/pvws- this should present the PVWS test page. User you browser to check that the new certificate is in use (should have later expiry date) -
Add a task to the group tasks list to renew the certificate with a due date one month before expiry
A gateway runs on NDAEXTWEB4 which is needed to only allow PVWS to access some PVs but not others.
This runs under the task scheduler as making a .bat run as a Windows service is not trivial.
the files in the top level (gw_* and start_gateway.bat) of this repo are located in C:\gateway on the machine it is running on. A static gateway build is also required (ie. from the latest static build of EPICS)
This points at control-svcs gateway, but denies everything that isn't in the gateway pvlist. It also only gives read-only access to any clients (in this case PVWS itself)
https://tomcat.apache.org/tomcat-9.0-doc/windows-service-howto.html
