I am a really beginner on this topic, I need some helpful articles and your guidance.
I want to build RESTFul
API web service. As a http server chosen nginx
. But I don't know (couldnt find any article) anything about how I can redirect my query to my java module, which handles request and gives back in JSON
to nginx
. If my thoughts on type of back-end is not correct please help me to figure out on this...
You will need to build your Java service in its own app server -- Tomcat would be a good choice for this. From there, it's a simple matter of configuring nginx
to act as a proxy to Tomcat. Your nginx
configuration will look something like the following:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
# multi_accept on;
}
http {
server {
listen 80; #incoming port for nginx
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
#...and other things, like basic settings, logging, mail, etc.
The important piece here is the setting for proxy_pass
. That's telling nginx
to accept requests on port 80 and redirect them to port 8080 (Tomcat's standard port).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With