Skip to content

Commit

Permalink
feat: nginx configs
Browse files Browse the repository at this point in the history
  • Loading branch information
aalexren committed Dec 9, 2023
1 parent 0cd3017 commit 9fe5a05
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 0 deletions.
79 changes: 79 additions & 0 deletions configs/web_server/nginx/api.pogaparking.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
upstream api {
server 0.0.0.0:8080;
}

server {
server_name api.pogaparking.ru;

if ($scheme != "https") {
return 301 https://$host$request_uri;
}

client_max_body_size 0;
chunked_transfer_encoding on;

proxy_buffering off;
proxy_request_buffering off;

location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
# Om nom nom cookies
#
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
proxy_pass http://api/;
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-Proto $scheme;

proxy_http_version 1.1;
proxy_set_header Connection "";
}

listen [::]:443; # managed by Certbot
ssl on;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/api.pogaparking.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/api.pogaparking.ru/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
if ($host = api.pogaparking.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80 ;
listen [::]:80 ;
server_name api.pogaparking.ru;
return 404; # managed by Certbot
}
55 changes: 55 additions & 0 deletions configs/web_server/nginx/docs.pogaparking.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
server {
server_name docs.pogaparking.ru;

if ($scheme != "https") {
return 301 https://$host$request_uri;
}

client_max_body_size 0;
chunked_transfer_encoding on;

proxy_buffering off;
proxy_request_buffering off;

location /swagger-ui/index.html {
proxy_pass http://0.0.0.0:8080/swagger-ui/index.html;
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-Proto $scheme;

proxy_http_version 1.1;
proxy_set_header Connection "";
}

location / {
proxy_pass http://0.0.0.0:8080/;
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-Proto $scheme;

proxy_http_version 1.1;
proxy_set_header Connection "";
}

listen [::]:443; # managed by Certbot
ssl on;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/docs.pogaparking.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/docs.pogaparking.ru/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
if ($host = docs.pogaparking.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80 ;
listen [::]:80 ;
server_name docs.pogaparking.ru;
return 404; # managed by Certbot
}
48 changes: 48 additions & 0 deletions configs/web_server/nginx/grafana.pogaparking.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
upstream grafana {
server 0.0.0.0:3000;
}

server {
server_name grafana.pogaparking.ru;

if ($scheme != "https") {
return 301 https://$host$request_uri;
}

client_max_body_size 0;
chunked_transfer_encoding on;

proxy_buffering off;
proxy_request_buffering off;

location / {
proxy_pass http://grafana/;
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-Proto $scheme;

proxy_http_version 1.1;
proxy_set_header Connection "";
}

listen [::]:443; # managed by Certbot
ssl on;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/grafana.pogaparking.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/grafana.pogaparking.ru/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
if ($host = grafana.pogaparking.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80 ;
listen [::]:80 ;
server_name grafana.pogaparking.ru;
return 404; # managed by Certbot
}
48 changes: 48 additions & 0 deletions configs/web_server/nginx/logs.pogaparking.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
upstream logs {
server 0.0.0.0:3100;
}

server {
server_name logs.pogaparking.ru;

if ($scheme != "https") {
return 301 https://$host$request_uri;
}

client_max_body_size 0;
chunked_transfer_encoding on;

proxy_buffering off;
proxy_request_buffering off;

location / {
proxy_pass http://logs/;
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-Proto $scheme;

proxy_http_version 1.1;
proxy_set_header Connection "";
}

listen [::]:443; # managed by Certbot
ssl on;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/logs.pogaparking.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/logs.pogaparking.ru/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
if ($host = logs.pogaparking.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80 ;
listen [::]:80 ;
server_name logs.pogaparking.ru;
return 404; # managed by Certbot
}
48 changes: 48 additions & 0 deletions configs/web_server/nginx/pogaparking.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
upstream backend {
server 0.0.0.0:5000;
}

server {
server_name pogaparking.ru;

if ($scheme != "https") {
return 301 https://$host$request_uri;
}

client_max_body_size 0;
chunked_transfer_encoding on;

proxy_buffering off;
proxy_request_buffering off;

location / {
return 301 $scheme://parking-web-ui.pages.dev$request_uri;
proxy_pass http://backend/;
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-Proto $scheme;

proxy_http_version 1.1;
proxy_set_header Connection "";
}

listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/pogaparking.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/pogaparking.ru/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
if ($host = pogaparking.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80 ;
listen [::]:80 ;
server_name pogaparking.ru;
return 404; # managed by Certbot
}

0 comments on commit 9fe5a05

Please sign in to comment.