Skip to content

Instantly share code, notes, and snippets.

@vinicius73
Last active June 15, 2022 13:51
Show Gist options
  • Save vinicius73/e8e447a8dfff457c3fcf7647a9e2fa02 to your computer and use it in GitHub Desktop.
Save vinicius73/e8e447a8dfff457c3fcf7647a9e2fa02 to your computer and use it in GitHub Desktop.
server {
listen 80;
listen [::]:80;
server_name api.x.app;
rewrite_log on;
# security
# include shared.d/security.conf;
merge_slashes off;
# logging
access_log /var/log/nginx/api.x.app.access.log;
error_log /var/log/nginx/api.x.app.error.log warn;
# restrict methods
if ($request_method !~ ^(GET|POST|OPTIONS)$) {
return '405';
}
# tem um loop aqui
location /servico-x {
if ($request_method = OPTIONS ) {
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET, OPTIONS, POST, PUT, DELETE";
add_header Access-Control-Allow-Headers "authorization, token, datasource, apollographql-client-name, content-type";
add_header Access-Control-Allow-Credentials "true";
add_header Content-Length 0;
add_header Content-Type text/plain;
return 200;
}
proxy_pass http://api-servico-x;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
# error pages
#location ~ /(50x|40x|404)\.html {
# root /app/html;
#}
# additional config
# include shared.d/general.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment