Nginx config for Rpi self-hosted

#1

It took me a while to figure how to configure it properly but it’s working now !

First, I don’t use “gBridge” in my config as explained in the documentation because the Auth page for google always redirect to https://YOUR-WEBSERVER’S-ADDRESS/gapi/auth so it’s a dead end for me.

So when creating your google action, use https://YOUR-WEBSERVER’S-ADDRESS/gapi link, and for the linking https://YOUR-WEBSERVER’S-ADDRESS/gapi/auth

For the nginx, I use this:

server {
    listen 80;
    listen 127.0.0.1;
    index index.php index.html;
    root /var/www/public;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass web-fpm:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
        gzip_static on;
    }
}

server {
    listen 443 ssl;

    #usually your public DNS name
    server_name YOUR-WEBSERVER'S-ADDRESS;

    #SSL-settings and generic server options here
   #YOUR SSL certificate parameters

    ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;

    proxy_ssl_session_reuse off;

    #the IP of the Docker host gBridge is running on
    set $gbridge_host 127.0.0.1;
    #the port is 80 because you're already in the container
    set $gbridge_port 80;
    location ~ ^/gapi/(.*)$ {
        #public access to the account dashboard is disabled for security reasons
        proxy_set_header Host $host;
        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 https;

        proxy_pass http://$gbridge_host:$gbridge_port/gapi/$1$is_args$args;
        }

    location ~ ^/gapi {
        #public access to the account dashboard is disabled for security reasons
        proxy_set_header Host $host;
        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 https;

        proxy_pass http://$gbridge_host:$gbridge_port/gapi;
        }
}

I’m not a nginx expert, maybe the 2 locations can be merged but due to the parameters (token…) used by google on the auth page, I had to implement it like this.

For the docker-compose, I followed this post till the last comment: https://github.com/kservices/gBridge-docker/issues/1

And now it’s running perfectly !!

@peter will the containers be updated ? the arm32 too ?

0 Likes