Working with the Prizm Application Services (PAS) > Prizm Application Services (PAS) How To's > Configuring PAS in your Server's Entry Point |
In the following examples, we will configure a route to reverse proxy all requests to the PAS service directly. We will use “pas-service” as the example route. First, we will configure the viewer to use this route -- this step will be the same regardless of which server you use.
In the index page of your viewer (Default.aspx in C#, index.php in the PHP sample, etc.), find the configured imageHandlerUrl
value and change it to “pas-service”. This will configure the viewer to send all of its requests to the “pas-service” endpoint. Note that all requests are sent relative to the index page, so you will have to make sure that the configured value is correct relative to the index page.
First, make sure that the URL Rewrite and Application Request Routing modules are installed.
Add an empty folder somewhere in your project. This folder will become the redirect endpoint for the service. In this example, we will name this folder “pas-service” and place it in the root of the web application.
In the Internet Information Services (IIS) Manager, navigate to the “pas-service” folder in your web application, and select “URL Rewrite” from the options on the right. Click “Add Rule(s)...” in the sidebar to open the rewriting rules menu.
This will result in the following web.config file in the empty “pas-service” folder:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:3000/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
You will need to make sure several modules are installed and enabled. These are: mod_proxy
, mod_proxy_http
, and mod_rewrite
.
On a Debian based system, you can execute the following:
sudo a2enmod rewrite
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo service apache2 restart
On CentOS/RHEL, or other deployments of Apache, you will need to modify the Apache config, typically in /etc/httpd/httpd.conf
or /etc/apache2/apache2.conf
, to load the required modules. Make sure the following lines exist toward the top of the file (typically where all other modules are loaded):
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
Note: these lines may already be present, or be present and commented out.
Find your Apache conf file for your application. Typically, the default is set up to be /etc/apache2/sites-enabled/000-default.conf
or /etc/httpd/httpd.conf
, but this may vary for your application.
Determine the url that you would like to proxy to PAS. In this example, we will assume that it is located at the root of the server and is named “pas-service” (e.g. http://myserver/pas-service).
Add the following to your application’s VirtualHost:
ProxyPass /pas-service http://localhost:3000
Make sure to restart Apache when done.
Add an empty folder somewhere in your project. This folder will become the redirect endpoint for the service. In this example, we will name this folder “pas-service” and place it in the root of the web application.
In order for .htaccess files to take effect, you may need to enable them. In the application config file, typically located at /etc/httpd/httpd.conf
or /etc/apache2/apache2.conf
, you will need to find the Directory declaration for your application. The default is /var/www/
. In the directory block, make sure the AllowOverride
line reads as such:
AllowOverride All
In the “pas-service” folder, add an .htaccess
file. Add the following content to the file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://localhost:3000$1 [L,P]
</IfModule>
Make sure to restart Apache when done.
Find your NginX conf file. Typically, this is located in /etc/nginx/nginx.conf
, or a conf file inside /etc/nginx/conf.d
or /etc/nginx/default.d
, depending on your specific configuration.
Find the server
block of the application in which you would like to deploy the viewer. In this example, we will assume the default server block.
Determine the url that you would like to proxy to PAS. In this example, we will assume that it is located at the root of the server and is named “pas-service” (e.g. http://myserver/pas-service). Add the following code in your server block:
location /pas-service/ {
rewrite ^/pas\-service(.*) $1 break;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:3000;
}
Note: If you are using SELinux, you may need to run this command if proxying to an external server:
sudo setsebool -P httpd_can_network_connect 1
Make sure to restart NginX when done.