How to Configure nginx for WebAPI Authentication
If you need to set up authentication for REST API FineReader Server 14 and Document Conversion Service calls, use the nginx http-server and httpd.
Note. This article describes how to set up authentication for a machine that has the WebAPI component installed.
- Set up the FineReader Server 14 website as follows:
- Open IIS Manager.
- In the Connections pane, expand Sites and the name of your server and select FineReader Server 14.
- In the Actions pane, select Bindings…
- Change the http Port from 8080 to 8079.
- Restart the website by clicking Restart in the Manage Website pane.
- Create a key file using htpasswd:
- Download Apache from the official Apache website and unpack it to the root folder of drive C:\.
- Save the key file to the root folder of drive C:\. To do so, run the following command:
C:\Apache24\bin\htpasswd -c c:\ nginx\conf\pass user1,
where user1 refers to the user and pass to the name of the key file. - When running the command, you will need to enter the password for user1 twice.
- To add a new user to an existing key file, run the following command:
C:\Apache24\bin\htpasswd c:\ nginx\conf\pass user2 - To verify that passwords have been created for all users, open the C:\pass file in Notepad:
user1:$apr1$8J02UMct$ElvPUHOsnAfj3ez0RSUoc/
user2:$apr1$zaBuoJjA$gZPUSmkxGI.DdSSdqLwqh1
- Set up nginx:
- Download nginx for Windows from the official nginx website and extract the installation package to the root folder of drive C:\.
- In the nginx/conf folder, open the key file and make sure that it looks like the following:
…
http {
…
server {
listen 8080;
server_name localhost;
location /FineReaderServer14{
proxy_pass http://localhost:8079;
auth_basic "Restricted Area";
auth_basic_user_file c:/nginx/conf/pass;
}
…
}
listen 8080 refers to the port that will be used by REST API FineReader Server 14 and the Document Conversion Service to send requests,
proxy_pass http://localhost:8079; is the port for the Document Conversion Service website,
and auth_basic_user_file c:/nginx/conf/pass is the path to the key file created using htpasswd.
- Launch nginx:
- Run the following command:
start C:\nginx-1.21.0\ nginx.exe - Verify that the process is running:
tasklist /fi "imagename eq nginx.exe"
Image Name | PID Session Name | Session# | Mem Usage |
nginx.exe | 3352 31C5CE94259D4006 | 2 | 6,960 K |
nginx.exe | 6432 31C5CE94259D4006 | 2 | 7,620 K |
The above will set up basic authentication for nginxHostName:8080/FineReaderServer14 calls.
Note. If you need to set up authentication of a different type, see the nginx help documentation.
26.03.2024 13:49:49