thenick775 / gbajs3

Gbajs3 is a full Game Boy Advance emulator online in the browser supporting the mGBA WASM core. It is freely licensed and works in any modern browser.
Other
41 stars 26 forks source link

ability to use a custom port for the web server #141

Closed Dhy19971 closed 4 months ago

Dhy19971 commented 4 months ago

Through the administrator panel I created a profile to be able to log in from the game interface (gbajs3-users). I tried to log in with both the player profile and the administrator profile (in the game session) but neither works.

I tried to change the password for gbajs3-users but there is no section to change it.

thenick775 commented 4 months ago

Do you have a video of what you're seeing?

Do you have an installation where I can attempt to log in?

Only the gbajs3-users will be able to log in to the emulator front end, so that is expected 😎

My best guess without more information is that your client host or ssl is potentially messed up.

I would look at your network tab for failing requests and post that output here as well!

Edit: thinking about this more, im interested in those network payloads, I bet its related to using a non-standard port (aside from 80/443) which maybe is causing problems

thenick775 commented 4 months ago

Some context: Currently I don't believe I allow for resetting user passwords. That may be a good enhancement.

I've left it off until I can get a proper registration flow going, but seems like that would be nice to have in the interim since admins are the only people allowed to add a user at this time, and i probably won't be implementing that feature soon.

Dhy19971 commented 4 months ago

I'll try to describe my case as best as I can.

Thsi is my .env try conf:

ROM_PATH=./server/auth/local_roms/
SAVE_PATH=./server/auth/local_saves/
CLIENT_HOST=https://192.168.178.10:4433
CERT_DIR=./server/auth/certs
CERT_LOC=$CERT_DIR/certificate.crt
KEY_LOC=$CERT_DIR/privateKey.key

ADMIN_APP_ID=12345678910b

PG_DB_HOST=gba-postgres
PG_DB_USER=postgres
PG_DB_PASSWORD=postgres
GBAJS_DB_NAME=gbajs3
ADMIN_DB_NAME=goadmin
PG_DB_PORT=5432
PG_SSL_MODE=disable
PG_DATA_LOCATION=./server/postgres/pg_data

This is my docker compose conf:

version: '2.1'
services:
    webserver:
        image: nginx
        logging:
            options:
                max-size: '20m'
                max-file: '3'
            driver: json-file
        build:
            context: ..
            dockerfile: ./docker/server/nginx/Dockerfile
            args:
                CLIENT_HOST: ${CLIENT_HOST}
        ports:
            - "4433:443"
            - "8033:80"
        depends_on:
            - gba-auth-server
            - gba-admin-server
        environment:
            - CLIENT_HOST=${CLIENT_HOST}
        cap_add:
            - NET_ADMIN
            - NET_RAW
        volumes:
            - ${CERT_LOC}:/certs/fullchain.pem
            - ${KEY_LOC}:/certs/privkey.pem

    gba-admin-server:
        image: gba-admin-server
        logging:
            options:
                max-size: '20m'
                max-file: '3'
            driver: json-file
        build:
            context: .
            dockerfile: ./server/admin/Dockerfile
        depends_on:
            gba-postgres:
                condition: service_healthy
        environment:
            - CLIENT_HOST=${CLIENT_HOST}
            - APP_ID=${ADMIN_APP_ID}
            - PG_DB_HOST=${PG_DB_HOST}
            - PG_DB_USER=${PG_DB_USER}
            - PG_DB_PASSWORD=${PG_DB_PASSWORD}
            - GBAJS_DB_NAME=${GBAJS_DB_NAME}
            - ADMIN_DB_NAME=${ADMIN_DB_NAME}
            - PG_DB_PORT=${PG_DB_PORT}
            - PG_SSL_MODE=${PG_SSL_MODE}
        volumes:
            - ${CERT_LOC}:/app/certs/fullchain.pem
            - ${KEY_LOC}:/app/certs/privkey.pem

    gba-auth-server:
        image: gba-auth-server
        logging:
            options:
                max-size: '20m'
                max-file: '3'
            driver: json-file
        build:
            context: .
            dockerfile: ./server/auth/Dockerfile
        depends_on:
            gba-postgres:
                condition: service_healthy
        environment:
            - CLIENT_HOST=${CLIENT_HOST}
            - PG_DB_HOST=${PG_DB_HOST}
            - PG_DB_USER=${PG_DB_USER}
            - PG_DB_PASSWORD=${PG_DB_PASSWORD}
            - PG_DB_NAME=${GBAJS_DB_NAME}
            - PG_DB_PORT=${PG_DB_PORT}
            - PG_SSL_MODE=${PG_SSL_MODE}
        volumes:
            - ${ROM_PATH}:/app/data/local_roms
            - ${SAVE_PATH}:/app/data/local_saves
            - ${CERT_LOC}:/app/certs/fullchain.pem
            - ${KEY_LOC}:/app/certs/privkey.pem

    gba-postgres:
        image: gba-postgres
        logging:
            options:
                max-size: '20m'
                max-file: '3'
            driver: json-file
        build:
            context: .
            dockerfile: ./server/postgres/Dockerfile
            args:
                PG_DB_USER: ${PG_DB_USER}
        environment:
            POSTGRES_USER: ${PG_DB_USER}
            POSTGRES_PASSWORD: ${PG_DB_PASSWORD}
            POSTGRES_DB: ${ADMIN_DB_NAME}
        command: postgres
        healthcheck:
            test: ["CMD-SHELL", "pg_isready -q -U ${PG_DB_USER} -d ${ADMIN_DB_NAME} -h ${PG_DB_HOST}"]
            interval: 10s
            timeout: 5s
            retries: 12
        volumes:
            - ${PG_DATA_LOCATION}:/var/lib/postgresql/data

Other conf is default.

Screenshot 2024-06-29 110946

Tell me what do you need and where i can find it.

Dhy19971 commented 4 months ago

This is a video where i try to create new user and login in frontend:

https://drive.google.com/file/d/1cwB1x7fxTGgPUsB0Hh_LW4hKdkx6YZyU/view?usp=drive_link

Dhy19971 commented 4 months ago

UPDATE:

I made a new instance where the default port is 80/443 and everything works correctly.

By changing port you lose the ability to log in.

It would be very useful to implement the possibility of using ports other than the default ones.

thenick775 commented 4 months ago

Awesome, glad it's confirmed

I'll do some work to make custom ports easier to use for the web server.

It's probably just not plumbed up properly when making network requests, as I never had a use case for this behavior originally!

I think this is a good enhancement 😎

thenick775 commented 4 months ago

Let me know if your still seeing issues with non-standard ports, I haven't been able to reproduce locally just yet.

My testing so far has included the following config:

# .env
...
CLIENT_HOST=https://localhost:8443
...

and the following changes to the compose file

diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml
index fcf75ca..7758c75 100644
--- a/docker/docker-compose.yaml
+++ b/docker/docker-compose.yaml
@@ -13,8 +13,8 @@ services:
             args:
                 CLIENT_HOST: ${CLIENT_HOST}
         ports:
-            - "443:443"
-            - "80:80"
+            - "8443:443"
+            - "8080:80"
         depends_on:
             - gba-auth-server
             - gba-admin-server

Producing the following result:

https://github.com/thenick775/gbajs3/assets/40526638/9766633f-c2bc-4f69-8b01-2678a37e3229

I do plan on potentially making this a lot easier to adjust, maybe with environment variables controlling the ports.

If you could show me the request payload/response/response code in the network tab of a debugger that would help me assist you!

On another note, you are also now able to properly edit the gbajs3 users in the admin now 😎

thenick775 commented 4 months ago

Closing for now as this looks to be working.

Feel free to continue to comment here or start a discussion if you need further assistance!