Created
July 10, 2022 21:11
-
-
Save ehfeng/f2c73e89fcd5d55119b37e928e82108f to your computer and use it in GitHub Desktop.
Mapping requests to localhost servers based on Accept header
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
events { | |
worker_connections 1024; | |
} | |
http { | |
map $http_accept $accept { | |
default app; | |
~text/html web; | |
} | |
upstream app { | |
server localhost:8888; | |
} | |
upstream web { | |
server localhost:3000; | |
} | |
server { | |
listen 8080; | |
server_name localhost; | |
location / { | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Forwarded-For $remote_addr; | |
proxy_pass http://$accept; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment