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

Nginx template for proxy management? #213

Closed
satonotdead opened this issue May 29, 2023 · 16 comments
Closed

Nginx template for proxy management? #213

satonotdead opened this issue May 29, 2023 · 16 comments

Comments

@satonotdead
Copy link

I wonder if someone can share their template to upstream Keila without exposing totally and only at localhost.

There are specific configurations that could fits well with Keila itself and not with another apps.

Kudos for great development! 🙏

@wmnnd
Copy link
Contributor

wmnnd commented Jun 4, 2023

There is no special configuration needed for serving user content. It’s just plain files which can be served with any web server, including Nginx. Just point the server to the directory you’ve configured in USER_CONTENT_DIR and set USER_CONTENT_BASE_URL to point to the address where your server will be available.

@wmnnd wmnnd closed this as completed Jun 4, 2023
@satonotdead
Copy link
Author

Thanks, I'm on Keila again and it seems to be super improved!

Tried to use Nginx with docker-compose and it run but when I try to compose a new campaign:

Can’t establish a connection to the server at wss://mail.cooldomain.co/live/websocket?_csrf_token=

Please, can you suggest how to enable this connection within the proxy? I tried to proxy the path to keila localhost exposed container but it didn't work.

@wmnnd
Copy link
Contributor

wmnnd commented Dec 17, 2023

Hey @satoshinotdead, you can find more details about setting up Nginx as a websocket proxy on the Nginx blog: https://www.nginx.com/blog/websocket-nginx/

The important bit is this bit in the location config which allows the browser to request an upgrade from a normal request to a Websocket:

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

@satonotdead
Copy link
Author

satonotdead commented Dec 17, 2023

Hi there! I tried this config before posting but it don't work:

        location / {
                proxy_pass http://127.0.0.1:4000;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }

And tried to proxy the /live/websocket location but it seems that's not the way to configure it and of course, didn't work too.

Do you know what I'm missing here? Thanks for your following up :)

@wmnnd
Copy link
Contributor

wmnnd commented Dec 17, 2023

Are you seeing anything in the nginx or in the Keila logs? Did you make sure to restart/reload nginx after updating your settings?

@wmnnd wmnnd reopened this Dec 17, 2023
@satonotdead
Copy link
Author

satonotdead commented Dec 17, 2023

I only see 403 forbidden console errors and this messages on logs:

Nginx reverse proxy (hosted on server)

connect() failed (111: Connection refused) while connecting to upstream

Keila Docker container

[error] Could not check origin for Phoenix.Socket transport.

I pruned containers and volumes, restarted and force-recreated but the issue persists. I suspect we need to tweak a little bit the Nginx template.

I will look into this and update if I find a solution.

@wmnnd
Copy link
Contributor

wmnnd commented Dec 17, 2023

Did you maybe not set the URL_HOST to the actual domain you’re using?

@wmnnd
Copy link
Contributor

wmnnd commented Dec 17, 2023

... or maybe you are missing the proxy_set_header Host $http_host; line in your nginx config.

@satonotdead
Copy link
Author

satonotdead commented Dec 18, 2023

Did you maybe not set the URL_HOST to the actual domain you’re using?

Tried localhost (127.0.0.1) and the https proxied and that was the same.

... or maybe you are missing the proxy_set_header Host $http_host; line in your nginx config.

Tried changing proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; for proxy_set_header Host $http_host; too, same result.

@wmnnd
Copy link
Contributor

wmnnd commented Dec 18, 2023

So you are trying to access Keila on localhost? If you are using a domain such as keila.example.com, you need to set URL_HOST=keila.example.com.

@satonotdead
Copy link
Author

Well, I'm using reverse proxy from Nginx so URL_HOST can be localhost (routed by Nginx from external internet, using the port locally exposed).

BTW I tried with our host (mail.domain.com) too but the wss socket issue persists.

@wmnnd
Copy link
Contributor

wmnnd commented Dec 18, 2023

No, it can’t be localhost, it needs to match your actual domain.

@satonotdead
Copy link
Author

Fair enough, checked (3 times). It's not working with URL_HOST pointing at my domain and just tested that variable on localhost.

I will update if I found something.

@wmnnd
Copy link
Contributor

wmnnd commented Dec 18, 2023

I hope you find a solution for your setup! Please keep up updated here in this issue in case someone else ends up having the same issue 😊

@wmnnd wmnnd closed this as completed Dec 18, 2023
@Marthaarman
Copy link

Have you found the solution?

Fair enough, checked (3 times). It's not working with URL_HOST pointing at my domain and just tested that variable on localhost.

I will update if I found something.

@satonotdead
Copy link
Author

satonotdead commented Sep 9, 2024

[EDIT] @Marthaarman no, I didn't find a solution. We are currently on #333 :)

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

3 participants