Skip to content

Commit

Permalink
Allow internal servers to have different listen configs.
Browse files Browse the repository at this point in the history
For when egress is on separate server.
  • Loading branch information
GUI committed Sep 29, 2023
1 parent 7c4e422 commit c8b12f9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions config/schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,19 @@ import "path"
api_server: {
host: string | *"127.0.0.1"
port: uint16 | *14010
listen: {
host: string | *"127.0.0.1"
port: uint16 | *14010
}
}

web: {
host: string | *"127.0.0.1"
port: uint16 | *14012
listen: {
host: string | *"127.0.0.1"
port: uint16 | *14012
}
request_timeout: uint | *30
workers: uint | "auto" | *2
worker_connections: uint | *8192
Expand Down Expand Up @@ -366,6 +374,10 @@ import "path"
static_site: {
host: string | *"127.0.0.1"
port: uint16 | *14013
listen: {
host: string | *"127.0.0.1"
port: uint16 | *14013
}
build_dir: string | *path.Join([_embedded_root_dir, "app/build/dist/example-website"])
}

Expand Down
4 changes: 2 additions & 2 deletions templates/etc/nginx/router.conf.etlua
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ http {
}

server {
listen <%- config["api_server"]["host"] %>:<%- config["api_server"]["port"] %> so_keepalive=<%- config["nginx"]["listen_so_keepalive"] %><% if config["nginx"]["listen_backlog"] then %> backlog=<%- config["nginx"]["listen_backlog"] %><% end %>;
listen <%- config["api_server"]["listen"]["host"] %>:<%- config["api_server"]["listen"]["port"] %> so_keepalive=<%- config["nginx"]["listen_so_keepalive"] %><% if config["nginx"]["listen_backlog"] then %> backlog=<%- config["nginx"]["listen_backlog"] %><% end %>;

set $x_api_umbrella_request_id $http_x_api_umbrella_request_id;

Expand Down Expand Up @@ -264,7 +264,7 @@ http {

<% if not config["_development_env?"] then %>
server {
listen <%- config["static_site"]["host"] %>:<%- config["static_site"]["port"] %> so_keepalive=<%- config["nginx"]["listen_so_keepalive"] %><% if config["nginx"]["listen_backlog"] then %> backlog=<%- config["nginx"]["listen_backlog"] %><% end %>;
listen <%- config["static_site"]["listen"]["host"] %>:<%- config["static_site"]["listen"]["port"] %> so_keepalive=<%- config["nginx"]["listen_so_keepalive"] %><% if config["nginx"]["listen_backlog"] then %> backlog=<%- config["nginx"]["listen_backlog"] %><% end %>;

set $x_api_umbrella_request_id $http_x_api_umbrella_request_id;
root <%- config["static_site"]["build_dir"] %>;
Expand Down
2 changes: 1 addition & 1 deletion templates/etc/nginx/web-app.conf.etlua
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ http {
init_worker_by_lua_file '<%- config["_src_root_dir"] %>/src/api-umbrella/web-app/hooks/init_worker.lua';

server {
listen <%- config["web"]["host"] %>:<%- config["web"]["port"] %> so_keepalive=<%- config["web"]["listen_so_keepalive"] %><% if config["web"]["listen_backlog"] then %> backlog=<%- config["web"]["listen_backlog"] %><% end %>;
listen <%- config["web"]["listen"]["host"] %>:<%- config["web"]["listen"]["port"] %> so_keepalive=<%- config["web"]["listen_so_keepalive"] %><% if config["web"]["listen_backlog"] then %> backlog=<%- config["web"]["listen_backlog"] %><% end %>;

set $x_api_umbrella_request_id $http_x_api_umbrella_request_id;

Expand Down

0 comments on commit c8b12f9

Please sign in to comment.