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

How would you go about adding nuxt admin app in /admin folder? #9

Closed
niqitos opened this issue Jan 26, 2020 · 1 comment
Closed

How would you go about adding nuxt admin app in /admin folder? #9

niqitos opened this issue Jan 26, 2020 · 1 comment

Comments

@niqitos
Copy link

niqitos commented Jan 26, 2020

Hi.

I have more of a question than an issue, but I didn't know how to contact you otherwise. I want to add separate admin nuxt app in /admin folder and connect it to /api. How would you go about setting up docker for this?

@nevadskiy
Copy link
Owner

nevadskiy commented Feb 5, 2020

Hi @niqitos. You can hit my telegram @nevadskiy.

Steps you need to do:

  1. Create an /admin folder for your admin app and specify a new port for your nuxt server because 3000 is already taken by the client app. 3001 might be good.

  2. Add a new service in the docker-compose.yml file (similar to the existing node service which fully serves the client app):

# Admin container
admin:
  build:
    context: docker/dev/admin
    dockerfile: Dockerfile
  volumes:
    - ./admin:/var/www/admin
  1. Create a new /docker/dev/admin folder from the existing /docker/dev/node folder and edit the Dockerfile inside of it according to the new structure.
# Image
FROM node:12.4-alpine

# Set up work directory
WORKDIR /var/www/admin

# Configure host
ENV HOST 0.0.0.0

# Init command
CMD ["sh", "-c", "yarn install && yarn dev"]
  1. Put a handler for listening a /admin location to the nginx configuration in the /docker/dev/nginx/default.conf file below the existing root handler. It might look something like that:
# Current root listener
location / {
        proxy_redirect                      off;
        proxy_set_header X-Real-IP          $remote_addr;
        proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto  $scheme;
        proxy_read_timeout                  1m;
        proxy_connect_timeout               1m;

        # Websocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;

        # Proxy to Node.JS instance
        proxy_pass http://node:3000;
}

# Your admin listener
location /admin {
        proxy_redirect                      off;
        proxy_set_header X-Real-IP          $remote_addr;
        proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto  $scheme;
        proxy_read_timeout                  1m;
        proxy_connect_timeout               1m;

        # Proxy to Node.JS instance of the 'admin' app
        proxy_pass http://admin:3001;
}
  1. Rebuild containers with make build command.

Hope it will work. Good luck.

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

2 participants