-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from gobengo/nginx_sub_path
Nginx sub path
- Loading branch information
Showing
29 changed files
with
3,119 additions
and
2,026 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# distbin/etc/distbin-nginx-subpath | ||
|
||
This demonstrates how to host distbin at a 'subpath' like `yourdomain.com/yourSubpath`. | ||
|
||
Motivated by this GitHub issue: https://github.com/gobengo/distbin/issues/20 | ||
|
||
It uses nginx as a reverse-proxy. End-user requests first hit nginx. If the HTTP request path starts with '/distbin/', nginx will remove that prefix from the request and forward the request to the running distbin process along a private network. | ||
|
||
distbin itself is run with the environment variable `EXTERNAL_URL=http://localhost:8001/distbin/` set. This allows distbin to render links to the prefixed URL without having to resort to bug-prone URL rewriting of the distbin-html HTML. | ||
|
||
## Usage | ||
|
||
From this directory, `docker-compose up` and access `http://localhost:8001`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
version: "3.4" | ||
|
||
networks: | ||
public: {} | ||
private: {} | ||
|
||
volumes: | ||
distbin-db: {} | ||
|
||
services: | ||
distbin-subpath-distbin: | ||
command: npm run start:ts-node | ||
environment: | ||
# Because with this docker networking setup, the running container cannot access EXTERNAL_URL | ||
- INTERNAL_URL=http://distbin-subpath-distbin:80/ | ||
- EXTERNAL_URL=http://localhost:8001/distbin/ | ||
- NODE_DEBUG=distbin | ||
- LOG_LEVEL=debug | ||
# - DISTBIN_DELIVER_TO_LOCALHOST=false | ||
build: ../../ | ||
networks: | ||
- private | ||
ports: | ||
- 80 | ||
volumes: | ||
- distbin-db:/distbin-db:rw | ||
# - .:/home/distbin/app | ||
|
||
distbin-subpath: | ||
depends_on: | ||
- distbin-subpath-distbin | ||
image: nginx:latest | ||
networks: | ||
- public | ||
- private | ||
volumes: | ||
- ./nginx.conf:/etc/nginx/nginx.conf | ||
ports: | ||
- 8001:80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
events { worker_connections 1024; } | ||
|
||
http { | ||
sendfile on; | ||
rewrite_log on; | ||
error_log /dev/stdout notice; | ||
access_log /dev/stdout; | ||
ignore_invalid_headers off; | ||
|
||
# upstream distbin-subpath-distbin { | ||
# server distbin-subpath-distbin:80; | ||
# } | ||
|
||
server { | ||
location /distbin/ { | ||
rewrite ^/distbin/(.*) /$1 break; | ||
proxy_pass http://distbin-subpath-distbin/; | ||
proxy_pass_request_headers on; | ||
proxy_redirect ~^/(.*) $scheme://$http_host/distbin/$1; | ||
proxy_set_header Host $http_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-Host $server_name; | ||
# proxy_set_header X-Forwarded-Host $host; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
} | ||
} |
Oops, something went wrong.