How to make an NFS volume accessible to Web Serving Apps
search cancel

How to make an NFS volume accessible to Web Serving Apps

book

Article ID: 297713

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

The purpose of this article is to explain how to make an NFS (Network File System) volume accessible to Web Serving Applications.

Environment


Cause

Currently an NFS volume service cannot be mounted under an applications document root. This causes staging failures during application re-staging.

An alternative method is needed to allow web servers, such as Nginx in the Static Buildpack, to serve content from an NFS volume.

Resolution

A workaround to this issue is to create a symbolic link from your NFS volumes mount point to a new directory under the Applications starting directory. Everything on the NFS Volume then becomes available for application usage by referencing that directory.

1. Create an NFS service that all our apps will mount:

cf create-service nfs Existing myapp -c '{"share":"10.1.2.3/exports/myappdocs"}'

2. Create a .profile file in your app directory. Add a command in the .profile to create a symbolic link from the bind service mount point to a directory where your app can access it. The static buildpack document root is /app/public

Note: You will bind the service in the step after this one, as you are pushing the app without a NFS Services section.

cat .profile
ln -s /var/myapp /app/public/myapp

cf push -f myapp.yml

3. Next bind your NFS service to the application:

cf bind-service myapp  myapp -c '{"uid":"1000","gid":"1000","mount":"/var/myapp"}'

cf restage myapp

4. To confirm the process was successful, access the content in the NFS volume by including the directory name in the URL.

curl http://myapp.apps.domain/myapp/index.html