Nginx with Java RESTl service

I am trying to run a Java REST service hosted locally on my Ubuntu instance with Nginx as reverse proxy

I’ve tried the following Nginx block while running the Java REST service using a bash script. The shell script points to conf.yaml file and its able to start the service without any problems and here’s the output after running shell

    root@instance-1:/var/www/html/jwebapi# bin/run.sh root/conf.yaml
    running  
    runtime path: root:dist/jservice.web.core.link.router.portal.gw.jar:build/lib/runtime/*
    verticle : !!jgroup.web.core.portal.gw.Config
    authDelay: 3000
    cors: {origin.allowed: '*', allowCredentials: false}
    ip2loc: US
    ips: allow: [x.*, x.x.*, 127.0.0.1, 10.148.0.1]
    deny: [x.x.x.x]
    listenPort: 5000
    listenSsl: true
    proxyRemoteHost: https://service.serviceportal.com
    proxyRemoteSsl: true
    sslCert: cert.jks
    sslPwd: myserviceapi
    webApps:- {cache: true, index: index.html, listing: false, name: demo, proxy: ''}

   -> mount demo on /demo
   Java Version: 1.8.0_222
   Open https://localhost:5000 to login
   App demo is available after you login under: https://localhost:5000/demo/

Here’s my Nginx block

server {
    listen 443;

    server_name mysubdomain.domain.com;

    location / {
        proxy_pass http://10.148.0.2:5000;
    }
}

And here’s my conf.yaml content

    // config.yaml
    ip2loc: "US"
    proxyRemoteSsl: true
    proxyRemoteHost: "https://service.serviceportal.com"
    listenPort: 5000
    listenSsl: true
    svcEnvironment: "v1"
    sslCert: "cert.jks"
    sslPwd: "myserviceapi"
    authDelay: 3000
    serverOptions:
        blockedThreadCheckInterval: 1000000
        eventLoopPoolSize: 20
        workerPoolSize: 20
        maxWorkerExecuteTime: 100
        internalBlockingPoolSize: 20
    cors:
        origin.allowed: "*"
        allowCredentials: false
    webApps:
        - name: "demo"
          index: "index.html"
    ips:
        allow:
         - x.*
         - x.x.*
         - 127.0.0.1
         - 10.148.0.2
    deny:
         - x.x.x.x

I am able to run this fine on my local environment as it directly opens the localhost:5000 but when I run this on my Ubuntu instance with an internal IP I am facing the above challenges.

I am looking to run this service on https://mysubdomain.domain.com instead of https://localhost:5000

Any help!

Leave a Reply

avatar
  Subscribe  
Notify of