Skip to content

Commit

Permalink
feat: nginx conf, for real this time
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfromyeg committed Jan 7, 2024
1 parent 6445760 commit f7f0447
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
map $http_user_agent $allowed_agent {
default "no";
~*DigitalOcean "yes";
}

server {
listen 80;
server_name api.bereal.michaeldemar.co;
Expand Down Expand Up @@ -32,19 +27,17 @@ server {
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;

location / {
if ($allowed_agent = "no") {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' 'https://bereal.michaeldemar.co';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';
add_header 'Content-Length' 0;
add_header 'Content-Type' 'text/plain; charset=utf-8';
return 204;
}
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' 'https://bereal.michaeldemar.co';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';
add_header 'Content-Length' 0;
add_header 'Content-Type' 'text/plain; charset=utf-8';
return 204;
}

if ($request_method !~ ^(GET|POST)$) {
return 403;
}
if ($request_method !~ ^(GET|POST)$) {
return 403;
}

proxy_pass http://web:5000;
Expand Down

0 comments on commit f7f0447

Please sign in to comment.