-
-
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.
Optional nginx config for Password Protection of frontend (#53)
* Optional nginx config for Password Protection of frontend NGINX configuration template that serves an application hosted on a Docker container at http://127.0.0.1:3000. This configuration includes basic authentication to restrict access to the application, ensuring that only authorized users can view the content. * Update nginx-conf Add additional comments * Update README.md Include NGINX Configuration in Readme * Update README.md
- Loading branch information
Showing
2 changed files
with
130 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
server { | ||
listen 80; | ||
server_name IP/DOMAIN; # Change to your Public IP Address or use a Domain with DNS A Record pointed to your Public IP address | ||
|
||
# Main location block to serve your application at / | ||
location / { | ||
# Create a user ` htpasswd -c /etc/nginx/.htpasswd USERNAMEHERE ` | ||
auth_basic "Restricted Area"; # This is the realm name that will appear in the authentication dialog | ||
auth_basic_user_file /etc/nginx/.htpasswd; | ||
|
||
proxy_pass http://127.0.0.1:3000/; | ||
proxy_set_header Host $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-Proto $scheme; | ||
proxy_set_header X-Forwarded-Host $host; | ||
|
||
proxy_set_header Origin http://127.0.0.1:3000; | ||
|
||
# Prevent proxying loops | ||
proxy_redirect off; | ||
|
||
# Allow serving static assets correctly | ||
try_files $uri $uri/ @proxy; | ||
|
||
# Disable buffering for proxied responses | ||
proxy_buffering off; | ||
} | ||
|
||
# Fallback for anything that doesn't match | ||
location @proxy { | ||
proxy_pass http://127.0.0.1:3000; | ||
proxy_set_header Host $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-Proto $scheme; | ||
proxy_set_header X-Forwarded-Host $host; | ||
|
||
proxy_set_header Origin http://127.0.0.1:3000; | ||
} | ||
} |