Skip to content

NativeDocumentsServices on Ubuntu

Florian Reuter edited this page Oct 9, 2015 · 8 revisions

Preparation / Setup

sudo apt-get update        # Always update!

Install NativeDocumentsServices as a Local Service (Recommended)

sudo apt-get install curl --yes && \
curl -O http://downloads.nativedocuments.com/NativeDocumentsServices.initd.x86_64.deb && \
sudo dpkg --install NativeDocumentsServices.initd.x86_64.deb && \
bash -c 'source /opt/NativeDocumentsServices/NativeDocumentsServices.config && \echo Listening on $NDS_SERVICE_ARGS'

Manually start / stop the service (optional)

sudo initctl stop NativeDocumentsServices    # start service manually
sudo initctl start NativeDocumentsServices   # stop service manually

Expose service externally (Not Recommended; Used for Debugging or Load Balancing Worker)

# Expose the service at port 9015
sudo initctl stop NativeDocumentsServices; \
sudo sed 's/^NDS_SERVICE_ARGS=.*$/NDS_SERVICE_ARGS=0.0.0.0:9015/g' -i /opt/NativeDocumentsServices/NativeDocumentsServices.config && \
sudo initctl start NativeDocumentsServices
# Open Firewall
sudo apt-get install iptables-persistent --yes && bash -c 'source /opt/NativeDocumentsServices/NativeDocumentsServices.config && sudo iptables -I INPUT -p tcp -m tcp --dport `echo $NDS_SERVICE_ARGS | sed s/.*://g` -j ACCEPT && sudo service iptables-persistent save'

Expose service via NGINX (Production System)

# Install NGINX
sudo /etc/init.d/nginx stop;
sudo apt-get install nginx --yes && \
sudo /etc/init.d/nginx stop; \
sudo bash -c 'source /opt/NativeDocumentsServices/NativeDocumentsServices.config && echo -e "\
server {\n\
  listen 8080;\n\
  location ~ \"^/v1/.+/.+\$\" {\n\
      if (\$request_method = GET) {\n\
         rewrite \"^/v1/.+/convert\$\" \"/\" permanent;\n\
      }\n\
      proxy_pass http://127.0.0.1:`echo $NDS_SERVICE_ARGS | sed s/.*://g`;\n\
      proxy_read_timeout 60m;\n\
      proxy_set_header Host \$host;\n\
      client_max_body_size 50m;\n\
  }\n\
  location / {\n\
      root /opt/NativeDocumentsServices;\n\
      rewrite ^ /converter.html break;\n\
  }\n\
  error_page   500 502 503 504  /50x.html;\n\
  location = /50x.html {\n\
      root   html;\n\
  }\n\
}\n" > /etc/nginx/conf.d/nds.conf' && sudo /etc/init.d/nginx start
# Open Firewall
sudo apt-get install iptables-persistent --yes && bash -c 'source /opt/NativeDocumentsServices/NativeDocumentsServices.config && sudo iptables -I INPUT -p tcp -m tcp --dport 8080 -j ACCEPT && sudo service iptables-persistent save'