PrizmDoc v12.0 - November 15, 2016
Configuring PrizmDoc Application Services in your Server's Entry Point

How to configure PrizmDoc Application Services in your Server's Entry Point

Configuring the viewer

In the following examples, we will configure a route to reverse proxy all requests to Applications Services 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.

Configure in IIS

First, make sure that the URL Rewrite and Application Request Routing modules are installed.

  1. In the start menu, type "Web Platform Installer". If this package manager is not installed, you can get it here: http://www.microsoft.com/web/downloads/platform.aspx
  2. In the search box, type "URL Rewrite".
  3. Find the latest version (as of this writing, it is 2.0), and click the "Add" button.
  4. Next, type "Application Request Routing" on the search box.
  5. Find the latest version (as of this writing, it is 3.0), and click the "Add" button.
  6. Click the "Install" button at the bottom and follow the prompts.

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.

  1. Select "Reverse Proxy" from the rule templates.
  2. A menu will pop up if this is the first time you are using this feature, to prompt that proxy functionality must be enabled in AAR. Click the "OK" button to enable it.
  3. We will assume that PrizmDoc Application Services is running in its default configuration on the same machine as your application, under port 3000. If you are running it on a different machine or a different port, you will need to know these values here. In this example, we will use "localhost:3000".
  4. In the server name box, enter the location of PrizmDoc Application Services. In our case, it is "localhost:3000".

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>

Configure in Apache

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.

Using the application conf file

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 PrizmDoc Application Services. 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.

Using an .htaccess file

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.

Configure in NginX

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 PrizmDoc Application Services. 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.

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback