Last active
April 22, 2024 07:51
-
-
Save bzdgn/6c648f91910be49e4a71b834e5f3b8bc to your computer and use it in GitHub Desktop.
Nginx Conf as Reverse Proxy for Keycloak
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
... | |
forwarder: | |
image: myngproxy:latest #coming from the local build docker image | |
ports: | |
- 9600:9600 | |
links: | |
- keycloak:keycloak | |
networks: | |
- mystack-app-net | |
... | |
networks: | |
mystack-app-net: | |
driver: bridge | |
external: true |
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
FROM nginx:latest | |
# Remove the default nginx configuration file | |
RUN rm /etc/nginx/conf.d/default.conf | |
# Copy a new configuration file from the current directory | |
COPY nginx.conf /etc/nginx/conf.d/ | |
# Expose ports | |
EXPOSE 9600 | |
# Start NGINX using the default command | |
CMD ["nginx", "-g", "daemon off;"] | |
# Build ngproxy before running dockerifle | |
# docker build -t myngproxy:latest . | |
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
server { | |
listen 9600; | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
location / { | |
proxy_pass http://keycloak:9001/; | |
proxy_set_header Host $host:$server_port; | |
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 $host; | |
proxy_set_header X-Forwarded-Server $host; | |
proxy_set_header X-Forwarded-Port $server_port; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment