Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use different ports behind nginx #25

Open
ValentinFunk opened this issue May 21, 2019 · 4 comments
Open

Use different ports behind nginx #25

ValentinFunk opened this issue May 21, 2019 · 4 comments

Comments

@ValentinFunk
Copy link

Hi, i'm trying to run this on google cloud run which requires to run on port 8080. Right now this port is used internally so it doesn't run when trying to use PORT=8080. Would it be possible to move the internal ports into a less frequently used port range? (like e.g. 32543)

@jgontrum
Copy link
Owner

I'm not experienced with Google Cloud, but the Docker container internally uses port 80 and AFAIK the host should not interfere with the internals of the container. When you start the container e.g. with docker run -p "127.0.0.1:8080:80" jgontrum/spacyapi:en_v2, you map the local port 8080 to the container port 80. So if 8080 doesn't work for you, can't you try -p "127.0.0.1:32543:80"?

@ValentinFunk
Copy link
Author

Unfortunately the requirements Cloud Run has is for the container is to listen to whatever port is specified in the PORT env variable. Unfortunately I cannot specify which port they use - they say that they use "8080" but this shouldn't be relied on, the app should support the PORT env variable at best.

I realize this is a bit of a limitation from the Cloud Run side as you usually have something to route to the container (using -p for docker bridge network, some reverse proxy, kubernetes service, ...) and it seems this is a bit unique to Cloud Run.

Would be cool if this could be changed here to support the use case, since otherwise it would require forking and it seems like it wouldn't break anything for current users to support it. Since you already have support for the PORT env variable it would only require changing the internal ports of the frontend and service which are not exposed right now.

To summarize, this is basically a feature request to support using PORT=8080 with the container :)
docker run -e PORT=8080 -p "8080" jgontrum/spacyapi:en_v2

BTW thank you very much for packaging this all up in an easy to use container! It's a fantastic time saver 😊

@koehlkm
Copy link

koehlkm commented Mar 31, 2020

I'm having a similar issue when trying to use Cloud Run. Has anyone had any success with deploying this on GCP or have any recommendations?

@premuifyify
Copy link

@kamshak I am facing the same issue here deploying on Cloud Run.

Basically Cloud Run prefers listening on the port 8080 and as the container is using nginx i have replaced the default.conf file to make nginx expose port 8080 as given on the link - https://stackoverflow.com/questions/47364019/how-to-change-the-port-of-nginx-when-using-with-docker#:~:text=If%20you%20want%20to%20change,conf%20file%20inside%20the%20container.&text=navigating%20to%20localhost%3A3333%20in,to%20include%20the%20default%20nginx.

** Dockerfile **

FROM jgontrum/spacyapi:base_v2
RUN pip install wheel
ENV languages "en_core_web_lg"
RUN cd /app && env/bin/download_models
COPY default.conf /etc/nginx/conf.d/
COPY nginx.conf /etc/nginx/
EXPOSE 8080

The problem is that it gives a 502 error on hitting any api. Here are the logs:

/usr/lib/python2.7/dist-packages/supervisor/options.py:461: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching '
2020-06-25 22:20:43,107 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, youcan set user=root in the config file to avoid this message.
2020-06-25 22:20:43,107 INFO Included extra file "/etc/supervisor/conf.d/supervisor.conf" during parsing
2020-06-25 22:20:43,132 INFO RPC interface 'supervisor' initialized
2020-06-25 22:20:43,132 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-06-25 22:20:43,133 INFO supervisord started with pid 7
2020-06-25 22:20:44,136 INFO spawned: 'nginx' with pid 10
2020-06-25 22:20:44,142 INFO spawned: 'api' with pid 11
2020-06-25 22:20:44,145 INFO spawned: 'frontend' with pid 12
2020-06-25 22:20:45,333 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-06-25 22:20:45,334 INFO success: api entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-06-25 22:20:45,334 INFO success: frontend entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-06-25 22:20:49,475 INFO exited: frontend (exit status 2; expected)
2020-06-25 22:21:34,723 INFO exited: api (exit status 2; expected)

I can't figure out what is the problem here. Any help is appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants