Install PxWeb 2 on your IIS server¶
This instruction guides you in how to install PxWeb 2 on IIS.
Prerequisites¶
- A supported Windows server with IIS installed.
- The URL Rewrite module must be installed on your IIS.
- ApiUrl to your PxWebApi 2 installation.
If your tables endpoint is at
https://your.api.server/PxWeb/api/v2/tablesthen your ApiUrl ishttps://your.api.server/PxWeb/api/v2(omit a trailing slash, one is added automatically)
Installation steps¶
- Download the zip file for the latest release from GitHub.
It is found inside the Asserts heading.
Make sure to Unblock it if its block by right clicking on it in File Explorer and check the
Unblockcheckbox. - Put the contents of the zip file to the location of your choice. E.g
C:\inetpub\wwwroot\pxweb2. -
Adjust
baseApplicationPathandapiUrlinconfig\config.js:baseApplicationPath: "/pxweb2/" apiUrl: "your api url" -
In
index.html, adjust the<base>tag:<base href="/pxweb2/"> -
In
web.config, adjust theContent-Security-Policyto allow calls to your PxWebApi 2 installation. Within theContent-Security-Policyreplace the texthttps://enter-your-api-domain-herewith the domain of your PxWebApi (for example https://api.scb.se):<add name="Content-Security-Policy" value="default-src 'self'; connect-src 'self' https://api.scb.se; script-src 'self'" /> -
In IIS find the folder and convert it to an application. (Consider using a separate Application pool for this)
-
Open "http(s)://"server adress"/pxweb2 .
Troubleshooting¶
Problem running PxWeb on localhost¶
If you are trying to run PxWeb directly on the server under localhost you might get an error looking like this in the console of your browser:
Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".
Solution¶
Change localhost in the URL to the computer name of the server.
PxWeb refuses to connect to PxWebApi¶
If you get an error message looking like this in the console of your browser:
Refused to connect to 'https://your-api-url' because it violates the following Content Security Policy directive: "connect-src 'self' https://enter-your-api-domain-here".
Solution¶
You need to enter the domain of your PxWebApi in the Content Security Policy section in web.config, see step 5 of the installation steps above.