├── Dockerfile ├── LICENSE ├── README.md └── nginx.conf /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx 2 | RUN cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bkp 3 | COPY nginx.conf /etc/nginx/nginx.conf 4 | EXPOSE 80:80 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Alexandre Brandão Lustosa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nginxApiGateway 2 | ## NGINX Api Gateway 3 | 4 | ```cs 5 | docker pull nginx 6 | docker build -t nginxapigateway . 7 | docker run --name nginxapigateway001 -t -i -p 80:80 -d nginxapigateway 8 | ``` 9 | 10 | #### Testar: 11 | ```cs 12 | http://127.0.0.1/depth 13 | http://127.0.0.1/ticker 14 | http://127.0.0.1/btc/brl 15 | ``` 16 | 17 | ![NGNIX](https://www.nginx.com/wp-content/uploads/2018/08/API-gateway-gRPC-sample-topology.png) 18 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes 1; 3 | 4 | error_log /var/log/nginx/error.log warn; 5 | pid /var/run/nginx.pid; 6 | 7 | 8 | events { 9 | worker_connections 1024; 10 | } 11 | 12 | http { 13 | include /etc/nginx/mime.types; 14 | default_type application/octet-stream; 15 | 16 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 17 | '$status $body_bytes_sent "$http_referer" ' 18 | '"$http_user_agent" "$http_x_forwarded_for"'; 19 | 20 | access_log /var/log/nginx/access.log main; 21 | 22 | sendfile on; 23 | #tcp_nopush on; 24 | 25 | keepalive_timeout 65; 26 | 27 | #gzip on; 28 | 29 | server { 30 | listen 80; 31 | 32 | location /depth { 33 | proxy_pass https://www.binance.com/api/v3/depth; 34 | } 35 | 36 | location /ticker { 37 | proxy_pass https://www.binance.com/api/v3/ticker/24hr; 38 | } 39 | 40 | location /btc/brl { 41 | proxy_pass https://www.mercadobitcoin.net/api/btc/ticker; 42 | } 43 | } 44 | 45 | include /etc/nginx/conf.d/*.conf; 46 | } --------------------------------------------------------------------------------