F
F
fdroid2018-07-25 22:10:19
Java
fdroid, 2018-07-25 22:10:19

How to proxy java application?

There is a Java web application nailed to Windows (running on local Jetty) and available at localhost:8080/app. The task is to provide access to the application from the outside by a domain name. I decided to use a Linux virtual machine with a real IP and a fixed domain, on which to launch nginx and proxy it to the Win machine using proxy_pass. Actually, I did this more than once, but it doesn’t work with such a bunch - either 500 Internal Error, or Authentication failed even without an authorization request, or a list of files opens in / app. Tried Apache and mod_proxy - same story.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
F
fdroid, 2018-07-26
@fdroid

In the end, I resolved the issue this way.
1) Using a direct link like my.domain/app, the application started to open, but using the link my.domain - a mess of service messages.
2) I had to use an intermediate index.html with a single link to the login page.
Final config (extra, such as ssl settings, removed)

server {
    server_name my.domain;
        root /var/www/mydomain;
        index index.html index.htm;

    location /app/ {
        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://192.168.0.100:8080/app/;
        client_max_body_size 1000M;
    }
}

S
Sergey Semenko, 2018-07-25
@abler98

Why proxy? You can forward the external 80/443 port to the internal 8080. Forwarding should be done in the router or in the system (if the wire is directly connected). Then set up A-records for your external IP.

A
Alexander Kuznetsov, 2018-07-26
@DarkRaven

Here is my working configuration for proxying Jira to the outside via nginx. Yes, I want to note that I have Jira on the same machine, and I have not tried proxying the application from the same network. But I don't see any problems here.

server {
    listen jira.orgname.local:80;
    server_name jira.orgname.local;
    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://jira.orgname.local:8080/;
        client_max_body_size 1000M;
    }
}

Also, I have cases of proxying through IIS - there I set Application Request Routing, URL Rewrite. In general, there is also nothing complicated and military.
Is it available at <PC-NAME>:8080/app, where PC-NAME is the name of your computer?
Simply, if it only listens on Localhost, it needs to be told to listen on 0.0.0.0 or some specific IP. Or pre-forward to an external port opened in the firewall.
UPD. I just tested this configuration for nginx and java application separated on different machines - everything worked right there, without any problems.
Try to check the application itself, maybe it has something that interferes with work.
Also, I would recommend reading here - https://serverfault.com/questions/824140/nginx-log... . In other words, you need to enable logging for proxy_pass and see what happens when an error occurs.

D
Dmitry Alexandrov, 2018-07-26
@jamakasi666

stackoverflow

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question