Ben Southall
Ben Southall

Reputation: 687

How to define nginx root when using a custom runtime in Google App Engine?

I'm using Google App Engine Flex and need to use a custom runtime so I can install some thirdparty libs. I need to define the document_root to be 'public', only the runtime_configs seems to get ignored when using a custom runtime, so this isn't working:

runtime_config:
   document_root: public

I've also tried adding in a nginx-app.conf file with the root declared (I'm also unsure how to get the app path, so i've just hardcoded it):

root "/app/public";

But I get the error:

nginx: [emerg] "root" directive is duplicate in /etc/nginx/conf.d/nginx-app.conf:1

I haven't been able to find the answer to this in the docs, so any help is appreciated!

Upvotes: 0

Views: 385

Answers (1)

komarkovich
komarkovich

Reputation: 2319

Following this Hello World example, you can see that root folder is declared in the nginx configuration file in your case nginx-app.conf

First of all you have to properly configure your Docker file, which will create public folder and copy all the files from local machine to it:

FROM nginx

COPY nginx.conf /etc/nginx/nginx.conf

RUN mkdir -p /usr/share/nginx/public/

# Copy static files from local public folder
ADD public/ /usr/share/nginx/public/
RUN chmod -R a+r /usr/share/nginx/public

Than you have to define a path to that public folder in nginx-app.conf file:

http {
    server {
        root /usr/share/nginx/public;
    }
}

Upvotes: 1

Related Questions