Giter Site home page Giter Site logo

Host Config & Reverse Proxy about soketi HOT 7 CLOSED

soketi avatar soketi commented on May 12, 2024
Host Config & Reverse Proxy

from soketi.

Comments (7)

francislavoie avatar francislavoie commented on May 12, 2024 4

Shameless plug, but I recommend using Caddy as your reverse proxy for this. Caddy has Automatic HTTPS, it can fetch certs from Let's Encrypt or ZeroSSL automatically. And you can use request matchers to decide to proxy to socketi instead of your PHP (or whatever) app if the request looks like websockets.

Example config, works for your standard Laravel app:

example.com {
	log

	@ws {
		header Connection *Upgrade*
		header Upgrade websocket
	}
	handle @ws {
		reverse_proxy socketi:6001
	}

	handle {
		root * /srv/public
		encode gzip
		php_fastcgi php-fpm:9000
		file_server
	}
}

@rennokki feel free to add this to the docs 👍

from soketi.

elbojoloco avatar elbojoloco commented on May 12, 2024 1

@xiCO2k Thank you for promoting Caddy here! Your reply has resulted in my entirely dropping nginx on my webserver and migrating everything, including the the reverse proxy for my websocket setup. This is so beautiful:

ws.mydomain.example {
        reverse_proxy 127.0.0.1:6001

        @websockets {
                header Connection *Upgrade*
                header Upgrade websocket
        }

        reverse_proxy @websockets 127.0.0.1:6001
}

from soketi.

francislavoie avatar francislavoie commented on May 12, 2024 1

In your case @elbojoloco since you're using the same upstream for both websockets and non-websockets, you don't need the @websockets matcher at all. Just do this:

ws.mydomain.example {
    reverse_proxy 127.0.0.1:6001
}

from soketi.

elbojoloco avatar elbojoloco commented on May 12, 2024 1

In your case @elbojoloco since you're using the same upstream for both websockets and non-websockets, you don't need the @websockets matcher at all. Just do this:

ws.mydomain.example {
    reverse_proxy 127.0.0.1:6001
}

Wow, amazing.. thanks for the tip!

from soketi.

rennokki avatar rennokki commented on May 12, 2024

what if I want to listen for private IP only?

Trying to understand this. Do you mean how to keep soketi non-public and use it just internally, for your other services?

And just want to know if this package would be better with or without reverse proxy like Nginx

Both are good. Adding reverse proxy adds some latency, but solves some configurational burdens when running in shared hosting with another backend app, especially for SSL.

from soketi.

banyu-wigara avatar banyu-wigara commented on May 12, 2024

@rennokki Yes, I want to put the websocket service for private use and also I want to have another one for public use but It's going to be behind Nginx, but the problem is the websocket service is listening to "0.0.0.0" or all interface, I want to know if it's possible to set which interface to listen to, like for the the one behind nginx will we "127.0.0.1" and the one for private will be "PRIVATE_IP"

from soketi.

rennokki avatar rennokki commented on May 12, 2024

HOST environment variable. It's not documented, I guess 😓

from soketi.

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.