NGINX error when deploying static website with Concourse CI

5.4k Views Asked by At

I encounter an error when I try to deploy a static website to Pivotal Web Services with Concourse CI. I want to push a static website using the static_buildpack. The index.html is placed in the root folder. When I push the code from the command line directly to Pivotal Web Services using the cf push command everything works fine.
When I use the concourse pipeline the build is terminated successfully however I get an error when accessing the website. I get an nginx 403 Forbidden error when trying to access the website. I tried the following manifest with the following pipeline (see below). When using Concourse CI the container is created successfully, the buildpack is used, nginx is installed and the droplet is uploaded. The app itself starts successfully.
The Cloud Foundry Logs show the following error:
2017/09/05 08:42:54 [error] 70#0: *3 directory index of "/home/vcap/app/public/" is forbidden, client: <ip>, server: localhost, request: "GET / HTTP/1.1", host: "agencydemo.cfapps.io"

manifest.yml

---
applications:
- name: agencyDemo
  memory: 64M
  buildpack: staticfile_buildpack
  host: agencyDemo

pipeline.yml

resources:
- name: app_sources
  type: git
  source:
    uri: https://github.com/smichard/CloudFoundryDemo
    branch: master

- name: staging_CloudFoundry
  type: cf
  source:
    api: {{pws_api}}
    username: {{pws_user}}
    password: {{pws_password}}
    organization: {{pws_org}}
    space: {{pws_space}}
    skip_cert_check: false

jobs:
- name: deploy-website
  public: true
  serial: true
  plan:
  - get: app_sources
    trigger: true
  - put: staging_CloudFoundry
    params:
        manifest: app_sources/manifest.yml

The source code can be found on GitHub

3

There are 3 best solutions below

0
On

You must ensure that index.html and other angular static files are directly present inside public/ folder and not in something like public/your-app-name/

0
On

Another solution is to fix the path-attribute in your manifest.yml as follows:

---
applications:
- name: agencyDemo
  memory: 64M
  buildpack: staticfile_buildpack
  host: agencyDemo
  path: ./dist/your-app-name

Docs

0
On

nginx 403 Forbidden happens mainly when index.html is not found. suggested steps

  1. Check your buildpack (which now is updated as buildpacks in manifest file)
  2. check command or dist folder

cf push -p ./dist/ -f manifest-{your_envireonment}.yml --no-start (if your index.html is directly under dist folder )

or

cf push -p ./dist/{your_app_name} -f manifest-{your_envireonment}.yml --no-start (if your index.html is under dist/{your_app_name} folder )