Giter Site home page Giter Site logo

Comments (7)

mpociot avatar mpociot commented on May 27, 2024

How did you setup expose and your nginx? Also how does your client connect to the server (which port)

from expose.

dakira avatar dakira commented on May 27, 2024

EDIT: Updated with my full nginx config

Hey Marcel. Thanks for looking at this. The following nginx config runs on *.example.com:

nginx.conf

server {
    listen IP_ADDRESS:443 ssl http2;

    server_name _.example.com;
    server_name ~^.*\.example\.com$;

    ssl_certificate      /etc/letsencrypt/live/example.com/full.pem;
    ssl_certificate_key  /etc/letsencrypt/live/example.com/full.pem;

    client_max_body_size 128m;

    root "/var/www/vhosts/example.com";
    access_log "/var/log/www/example.com/access_ssl_log";
    error_log "/var/log/www/example.com/error_log";

    location / {
        proxy_pass         http://127.0.0.1:3250;
        proxy_set_header   Host $http_host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
        proxy_cache_bypass $http_upgrade;

        proxy_read_timeout     60;
        proxy_connect_timeout  60;
        proxy_redirect         off;
    }
}

*.example.com also has a proper wildcard letsencrypt certificate set up.

The expose config on the server looks like this:

Server: .expose/config.php
<?php

return [
    'host' => 'niess.space',
    'port' => 443,
    'auth_token' => '',
    'default_tld' => 'test',
    'max_logged_requests' => 25,
    'memory_limit' => '128M',
    'skip_body_log' => [
        'status' => [
            // "4*"
        ],
        'content_type' => [
            //
        ],
        'extension' => [
            '.js.map',
            '.css.map',
        ],
        'size' => '1MB',
    ],
    'admin' => [
        'database' => implode(DIRECTORY_SEPARATOR, [
            $_SERVER['HOME'] ?? __DIR__,
            '.expose',
            'expose.db',
        ]),
        'validate_auth_tokens' => true,
        'maximum_connection_length' => 0,
        'subdomain' => 'expose',
        'subdomain_generator' => \App\Server\SubdomainGenerator\RandomSubdomainGenerator::class,
        'users' => [
            'admin' => 'password',
        ],
        'user_repository' => \App\Server\UserRepository\DatabaseUserRepository::class,
        'messages' => [
            'message_of_the_day' => 'Thank you for using expose.',
            'invalid_auth_token' => 'Authentication failed. Please check your authentication token and try again.',
            'subdomain_taken' => 'The chosen subdomain :subdomain is already taken. Please choose a different subdomain.',
        ],
    ],
];

I run the server with expose serve example.com --port 3250

The client config looks like this:

Server: .expose/config.php
<?php

return [
    'host' => 'a.example.com',
    'port' => 443,
    'auth_token' => 'myauthtoken',
    'default_tld' => 'test',
    'max_logged_requests' => 25,
    'memory_limit' => '128M',
    'skip_body_log' => [
        'status' => [
            // "4*"
        ],
        'content_type' => [
            //
        ],
        'extension' => [
            '.js.map',
            '.css.map',
        ],
        'size' => '1MB',
    ],
    'admin' => [
        'database' => implode(DIRECTORY_SEPARATOR, [
            $_SERVER['HOME'] ?? __DIR__,
            '.expose',
            'expose.db',
        ]),
        'validate_auth_tokens' => false,
        'maximum_connection_length' => 0,
        'subdomain' => 'expose',
        'subdomain_generator' => \App\Server\SubdomainGenerator\RandomSubdomainGenerator::class,
        'users' => [
            'username' => 'password',
        ],
        'user_repository' => \App\Server\UserRepository\DatabaseUserRepository::class,
        'messages' => [
            'message_of_the_day' => 'Thank you for using expose.',
            'invalid_auth_token' => 'Authentication failed. Please check your authentication token and try again.',
            'subdomain_taken' => 'The chosen subdomain :subdomain is already taken. Please choose a different subdomain.',
        ],
    ],
];

Notice, that I use port 443 to connect to a.example.com because example.com is already in use on the server hosting a website. Kind of a hack, but it works. I can successfully expose my sites and see the result at https://{subdomain}.example.com (manually removing the "a"). I can also open https://expose.example.com to generate my login token. Shared sites are shown in the backend as http://{subdomain}.example.com:3250 (I think they should be shown as https://{subdomain}.example.com, though).

The only problem is that all links generated by the route helper point to http://{subdomain}.example.com:3250.

from expose.

mpociot avatar mpociot commented on May 27, 2024

hm that all looks good. And is pretty much my setup too. Could you show me the headers that you see in your dashboard when sharing a local url?

from expose.

dakira avatar dakira commented on May 27, 2024

Here you go:
redacted

from expose.

mpociot avatar mpociot commented on May 27, 2024

I noticed that the nginx config is indeed different than mine:

proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto  https;

Could you try adding those headers?

from expose.

dakira avatar dakira commented on May 27, 2024

Perfect, that works. I'll PR the docs.

from expose.

mpociot avatar mpociot commented on May 27, 2024

Awesome, thanks!

from expose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.