This project support config Nginx as a gateway automatically. Can use the project for a replacement for Spring Cloud Gateway when you run it along with Nginx. Currently, only implement Discovery Client for Eureka Discovery.
You have to set up a microservices project that has at least a Discovery Service. The Discovery Service is using Eureka.
Let say Nginx config locate at /usr/local/etc/nginx/
.
-
Execute these commands:
$ cd /usr/local/etc/nginx/ $ mkdir conf.d $ touch default.conf $ touch server.conf
-
Set
nginx.conf
like this:events { worker_connections 1024; } http { include mime.types; # Include default.conf here include /usr/local/etc/nginx/conf.d/default.conf; default_type application/octet-stream; sendfile on; keepalive_timeout 65; #gzip on; # Include server.conf here include /usr/local/etc/nginx/conf.d/server.conf; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } } }
-
Add this configuration in
application.yml
nginx: where: /usr/local/bin/nginx load-balancing-config-file: /usr/local/etc/nginx/conf.d/default.conf proxy-config-file: /usr/local/etc/nginx/conf.d/server.conf load-balancing-template: classpath:nginx/conf.d/default.conf server-template: classpath:nginx/conf.d/server.conf proxy-template: classpath:nginx/conf.d/location.conf