Hosting static content

NGINX as a Service for Azure supports hosting static content which allows users to serve static websites from their deployment.

Uploading static files as a tarball

Follow the steps listed below to upload static content and relevant NGINX configuration using tar:

  1. Create an nginx.conf to configure your deployment to serve static content. The following is an example NGINX configuration:
http {
	server {
		listen 80;
		location / {
			root /srv;
			index index.html;
		}
	}
}
  1. Store your static files alongside the NGINX configuration.

The following shows the structure of a directory containing an NGINX configuration and an index.html file that we will be served from the deployment.

test-static-files $ tree .
.
├── nginx.conf
└── srv
    └── index.html

2 directories, 2 files
Note:
index.html is placed under the srv directory. When using tar to upload static content, the static content has to be placed under one of the allowed paths listed in the Filesystem Restrictions Table.
  1. Create the tarball.
test-static-files $ tar -cvzf <path to store tarball>/test.tar.gz *
  1. Upload the tarball following instructions listed in the NGINX configuration documentation.

  2. After uploading the configuration, you should see the following files in your deployment:

    NGINX Static Content Configuration

  3. Browse to the deployment IP address, and you will see index.html being served from the deployment.

Uploading static files directly to the deployment

You can also upload static files directly to the deployment. See Adding NGINX Configuration to upload individual files to your deployment. Refer to the Filesystem Restrictions Table to see where files can be written to and read from.

Limitations

NGINX Configuration payload larger than 3 MB is not supported.