Solved

How to set up nginx server to proxy to a java application

Posted on 2016-08-16
5
81 Views
Last Modified: 2016-08-22
I have a nginx server sitting on dmz to poing traffic to a java application.  The reason why i call it java application is because it only has a xxx.jar file running. I could like to proxy the http traffic to the java application. The port is poart 80. I did the following nginx configuration as below, but it doesn't work. Is there any nginx experts here can help me with this issue?


[root@pmsdev jyu]# ps -ef | grep java
root      3108     1  0 13:29 ?        00:01:56 java -Dspring.profiles.active=dev -jar /data/AveryRollProduction.jar /tmp
root      3933  3918  0 17:24 pts/0    00:00:00 grep --color=auto java



    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        # server_name  localhost;
        # root         /usr/share/nginx/html;

        server_name  localhost;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {

        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://10.104.0.104:80;



        }

Open in new window

0
Comment
Question by:Jason Yu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 41759760
you need to be running a web server that has the .jar file running at all times.  A jar file by itself is simply a file that contains instructions for use by java
0
 
LVL 40

Expert Comment

by:noci
ID: 41760194
And the Java application is listening on port 80?

you can verify the listening port by using
netstat -antp  

on the server where the java application is active....
(there is a <pid>/java at the end of the line)

And then stop this server and use netstat -antp again to verfy the ports used.
And if listening on port 80, and using http you should be able to verify it's working by using a browser to that addresses.
0
 

Accepted Solution

by:
Jason Yu earned 0 total points
ID: 41760277
Thanks guys, I got it resoled by set up reverse proxy.
0
 

Author Comment

by:Jason Yu
ID: 41760278
I commented out the root line and add a new one.

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        # server_name  localhost;
        # root         /usr/share/nginx/html;

        server_name  localhost;
        #root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        proxy_pass http://10.104.0.104:80;
        }

        # redirect server error pages to the static page /40x.html
        #
        error_page 404 /404.html;
            location = /40x.html {
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
0
 

Author Closing Comment

by:Jason Yu
ID: 41765046
I found the solution.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question