Last active
August 9, 2024 22:38
-
-
Save mebaysan/5cb99fafd243e2ad178accf78aee9e24 to your computer and use it in GitHub Desktop.
donation app fe on Caprover | proxy with be app
This file contains hidden or 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
<% | |
if (s.forceSsl) { | |
%> | |
server { | |
listen 80; | |
server_name <%-s.publicDomain%>; | |
# Used by Lets Encrypt | |
location /.well-known/acme-challenge/ { | |
root <%-s.staticWebRoot%>; | |
} | |
# Used by CapRover for health check | |
location /.well-known/captain-identifier { | |
root <%-s.staticWebRoot%>; | |
} | |
location / { | |
return 302 https://$http_host$request_uri; | |
} | |
#BAYSAN ADDED | |
location /django-static/ { | |
alias /nginx-shared/babialem-be/static/; | |
} | |
location /django-media/ { | |
alias /nginx-shared/babialem-be/media/; | |
} | |
} | |
<% | |
} | |
%> | |
server { | |
<% | |
if (!s.forceSsl) { | |
%> | |
listen 80; | |
<% | |
} | |
if (s.hasSsl) { | |
%> | |
listen 443 ssl http2; | |
ssl_certificate <%-s.crtPath%>; | |
ssl_certificate_key <%-s.keyPath%>; | |
<% | |
} | |
%> | |
client_max_body_size 500m; | |
server_name <%-s.publicDomain%>; | |
# 127.0.0.11 is DNS set up by Docker, see: | |
# https://docs.docker.com/engine/userguide/networking/configure-dns/ | |
# https://github.com/moby/moby/issues/20026 | |
resolver 127.0.0.11 valid=10s; | |
# IMPORTANT!! If you are here from an old thread to set a custom port, you do not need to modify this port manually here!! | |
# Simply change the Container HTTP Port from the dashboard HTTP panel | |
set $upstream http://<%-s.localDomain%>:<%-s.containerHttpPort%>; | |
#BAYSAN ADDED | |
location /django-static/ { | |
alias /nginx-shared/babialem-be/static/; | |
} | |
location /django-media/ { | |
alias /nginx-shared/babialem-be/media/; | |
} | |
location / { | |
<% | |
if (s.redirectToPath) { | |
%> | |
return 302 <%-s.redirectToPath%>; | |
<% | |
} else { | |
%> | |
<% | |
if (s.httpBasicAuthPath) { | |
%> | |
auth_basic "Restricted Access"; | |
auth_basic_user_file <%-s.httpBasicAuthPath%>; | |
<% | |
} | |
%> | |
proxy_pass $upstream; | |
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; | |
<% | |
if (s.websocketSupport) { | |
%> | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_http_version 1.1; | |
<% | |
} | |
%> | |
<% | |
} | |
%> | |
} | |
# Used by Lets Encrypt | |
location /.well-known/acme-challenge/ { | |
root <%-s.staticWebRoot%>; | |
} | |
# Used by CapRover for health check | |
location /.well-known/captain-identifier { | |
root <%-s.staticWebRoot%>; | |
} | |
error_page 502 /captain_502_custom_error_page.html; | |
location = /captain_502_custom_error_page.html { | |
root <%-s.customErrorPagesDirectory%>; | |
internal; | |
} | |
} |
This file contains hidden or 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
<% | |
if (s.forceSsl) { | |
%> | |
upstream donation_app_be { | |
server srv-captain--babialem-be:8000; | |
} | |
server { | |
listen 80; | |
server_name <%-s.publicDomain%>; | |
# Used by Lets Encrypt | |
location /.well-known/acme-challenge/ { | |
root <%-s.staticWebRoot%>; | |
} | |
# Used by CapRover for health check | |
location /.well-known/captain-identifier { | |
root <%-s.staticWebRoot%>; | |
} | |
location / { | |
return 302 https://$http_host$request_uri; | |
} | |
#BAYSAN | |
location /django-static/ { | |
alias /nginx-shared/babialem-be/static/; | |
} | |
location /django-media/ { | |
alias /nginx-shared/babialem-be/media/; | |
} | |
# Django App | |
location /cockpit { | |
proxy_pass http://donation_app_be; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
proxy_redirect off; | |
} | |
# Django App | |
location /api { | |
proxy_pass http://donation_app_be; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
proxy_redirect off; | |
} | |
} | |
<% | |
} | |
%> | |
server { | |
<% | |
if (!s.forceSsl) { | |
%> | |
listen 80; | |
<% | |
} | |
if (s.hasSsl) { | |
%> | |
listen 443 ssl http2; | |
ssl_certificate <%-s.crtPath%>; | |
ssl_certificate_key <%-s.keyPath%>; | |
<% | |
} | |
%> | |
client_max_body_size 500m; | |
server_name <%-s.publicDomain%>; | |
# 127.0.0.11 is DNS set up by Docker, see: | |
# https://docs.docker.com/engine/userguide/networking/configure-dns/ | |
# https://github.com/moby/moby/issues/20026 | |
resolver 127.0.0.11 valid=10s; | |
# IMPORTANT!! If you are here from an old thread to set a custom port, you do not need to modify this port manually here!! | |
# Simply change the Container HTTP Port from the dashboard HTTP panel | |
set $upstream http://<%-s.localDomain%>:<%-s.containerHttpPort%>; | |
#BAYSAN | |
location /django-static/ { | |
alias /nginx-shared/babialem-be/static/; | |
} | |
location /django-media/ { | |
alias /nginx-shared/babialem-be/media/; | |
} | |
# Django App | |
location /cockpit { | |
proxy_pass http://donation_app_be; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
proxy_redirect off; | |
} | |
# Django App | |
location /api { | |
proxy_pass http://donation_app_be; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
proxy_redirect off; | |
} | |
location / { | |
<% | |
if (s.redirectToPath) { | |
%> | |
return 302 <%-s.redirectToPath%>; | |
<% | |
} else { | |
%> | |
<% | |
if (s.httpBasicAuthPath) { | |
%> | |
auth_basic "Restricted Access"; | |
auth_basic_user_file <%-s.httpBasicAuthPath%>; | |
<% | |
} | |
%> | |
proxy_pass $upstream; | |
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; | |
<% | |
if (s.websocketSupport) { | |
%> | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_http_version 1.1; | |
<% | |
} | |
%> | |
<% | |
} | |
%> | |
} | |
# Used by Lets Encrypt | |
location /.well-known/acme-challenge/ { | |
root <%-s.staticWebRoot%>; | |
} | |
# Used by CapRover for health check | |
location /.well-known/captain-identifier { | |
root <%-s.staticWebRoot%>; | |
} | |
error_page 502 /captain_502_custom_error_page.html; | |
location = /captain_502_custom_error_page.html { | |
root <%-s.customErrorPagesDirectory%>; | |
internal; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment