0

I am using docker with three containers - backend/frontend/admin. I would like to use such proxy pass to navigate either to admin page or frontend -

<VirtualHost *:80>
    ServerName cookie.com
    ServerAlias www.cookie.com

    # Proxy requests to frontend
    ProxyPass / http://frontend:4200/
    ProxyPassReverse / http://frontend:4200/

    # Proxy requests to backend with the appropriate path
    ProxyPass /admin http://admin:8080
    ProxyPassReverse /admin  http://admin:8080

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

My frontend .ember-cli has proxy with this value - "proxy": "http://backend/ratata/backend/public/index.php"

It was working perfectly fine, when I used backend container port 5004:80, but now when using 80:80 its not.

So when I navigate to localhost it loads all the stuff except some requests and then i get in apache logs this and it hangs the request up to timeout of around 2 minutes. -

[mpm_prefork:error] [pid 347] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting

I also get this -

(20014)Internal error (specific information not available): [client 172.22.0.2:52218] AH01102: error reading status line from remote server frontend:4200, referer: http://localhost/
[Thu Feb 15 17:31:22.102014 2024] [proxy:error] [pid 516] [client 172.22.0.2:52218] AH00898: Error reading from remote server returned by /api/v1/settings, referer: http://localhost/

I am clueless what could be wrong here!

Thanks

1 Answer 1

1

ember-cli isn't meant to run on servers, but during deployment, projects can be "built" (via ember build --environment=production), and then some server (such as your backend, or nginx) serves those built assets.

here is an example of how to serve static assets in an nginx.conf

server {
    listen       ${NGINX_LISTENING_PORT};
    server_name  localhost;

    gzip on;
    gzip_disable "msie6";

    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd+api.json;

    location / {
        root   /emberclear;

        try_files $uri /index.html;
    }
}

in particular, you want to look at try_files's documentation for your own dockerfile + nginx config


in a docker environment, I bootstrapped nginx via this shell script:

#!/usr/bin/env sh

export NGINX_LISTENING_PORT=${PORT:-80}
export VARS_TO_REPLACE='$NGINX_LISTENING_PORT'

if [ "$NGINX_CONF_DIR" = "" ]
then
    NGINX_CONF_DIR=/etc/nginx/conf.d
fi

envsubst "$VARS_TO_REPLACE" < $NGINX_CONF_DIR/default.conf.template > $NGINX_CONF_DIR/default.conf
cat $NGINX_CONF_DIR/default.conf

echo "Starting emberclear..."
nginx -g 'daemon off;'

and this is the entire Dockerfile I had for an nginx-only docker container:

FROM nginx:alpine

COPY dist/ /emberclear
COPY scripts/docker/run-nginx.sh /usr/local/bin
COPY scripts/docker/nginx.conf etc/nginx/conf.d/default.conf.template

EXPOSE 4201
CMD ["/usr/local/bin/run-nginx.sh"]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.