How to change the port of the service gateway in a logom application? - lagom

I have created the getting started lagom application http://www.lagomframework.com/documentation/1.0.x/GettingStarted.html
And the system is starting fine.
[info] Service locator is running at http://localhost:8000
[info] Service gateway is running at http://localhost:9000
[info] application - Signalled start to ConductR
[info] application - Signalled start to ConductR
[info] Service hellostream-impl listening for HTTP on 0:0:0:0:0:0:0:0:26230
[info] Service helloworld-impl listening for HTTP on 0:0:0:0:0:0:0:0:24266
How do i change the host and port of the service gateway to listen on 0.0.0.0:8080 ?

The hostname seems to be fine. It's possible to access the service from another machine. The localhost is hard coded.
def serviceGatewayAddress: URI = {
new URI(s"http://localhost:${gateway.address.getPort}")
}
see https://github.com/lagom/lagom/blob/1.0.0-M1/dev/service-locator/src/main/scala/com/lightbend/lagom/discovery/ServiceLocatorServer.scala#L71
To configure the port of the service gateway set the property lagomServiceGatewayPort in the main build.sbt.
lagomServiceGatewayPort in ThisBuild := 8080

Related

traefik route configuration with http and https

Our web application is already running on on-prem Kubernetes setup with the following traefik configuration. The HTTPS endpoints are working fine, and now we need to add two services that run on HTTP with their own specific ports.
So basically we need to do the following routing:
[existing setup]
HTTPS adminapp.mydomain.com -> Admin UI App
HTTPS myapp.mydomain.com -> UI App
HTTPS api.mydomain.com -> Backend API
[new services]
HTTP api.mydomain.com:8111 -> Service1 API Integration with HTTP
HTTP api.mydomain.com:9111 -> Service2 API Integration with HTTP
Service1 and Service2 are intranet systems that will send the data to their own specific ports.
Here is the traefik configuration:
## Entrypoint Configurations
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
service1:
address: ":8111"
service2:
address: ":9111"
----
## Service1 IngressRoute
entryPoints:
- service1
routes:
- match: Host(`api.mydomain.com`)
kind: Rule
services:
- name: service1-clusterip-service
port: 8111
----
## Service2 IngressRoute
entryPoints:
- service2
routes:
- match: Host(`api.mydomain.com`)
kind: Rule
services:
- name: service2-clusterip-service
port: 9111
When we try to call the Service1 service with the following API http://api.mydomain.com:8111/path/arg/item over the HTTP request, getting this specific error.
upstream connect error or disconnect/reset before headers. reset reason: connection failure, transport failure reason: delayed connect error: 111
There is not much detail in the access logs as well to identify where the request is breaking.
We have a middleware to force redirect from HTTP to HTTPS, but that is removed to test the above configurations.
Any idea on why the configuration is not working as expected!!
Issue resolved. We found a typo in the service that was pointing to the wrong pod selector.
Also, our setup changed a bit so putting it here if anyone else faces the same issue.
[existing setup]
HTTPS adminapp.mydomain.com -> Admin UI App
HTTPS myapp.mydomain.com -> UI App
HTTPS api.mydomain.com -> Backend API
[new services]
HTTP api.mydomain.com:8111 -> Service1 API Integration with HTTP
TCP api.mydomain.com:9111 -> Service2 API Integration with TCP
For TCP integration make sure you follow these:
Entrypoint is defined with :port/tcp
Router is defined with IngressRouterTCP
If you are doing then host check, then use the HostSNI(`*`) if tls is disabled.

How to enable AJP port in Payara Micro and Use Apache server as proxy

I am using Payara micro community edition to deploy a microservice REST APIs. I need to enable AJP port so that the Apache proxy server listens to the AJP port 8192.
java -jar payara-micro-5.2020.5.jar --deploydir ./payara/webapps --rootDir ./payara --postbootcommandfile ./payara/postboot.txt
./payara/webapps folder contains the microservice WAR file.
postboot.txt content:
create-network-listener --protocol http-listener-1 --listeneraddress 0.0.0.0 --listenerport 8192--jkenabled true jk-connector
The command execution has no issues and following ports are enabled "Http Port(s)": "8080, 8192".
I am able to use the microservice APIs locally (http://localhost:8192/). But the requests from Apache proxy shows Bad Gateway error.
Am I missing some configuration for AJP port enabling in Payara Micro?
AJP port is enabled for Payara by adding this line in the domain.xml
<network-listener protocol="jk-listener" jk-enabled="true" port="8192" name="jk-connector" thread-pool="http-thread-pool" transport="tcp"></network-listener>

Logs reporting Traefik is unable to find Docker socket at wrong endpoint

Currently trying to setup a Docker socket proxy container. I've added the new tcp address as the Docker endpoint in traefik.toml but the logs report that Traefik is unable to connect to the daemon at the standard address "unix:///var/run/docker.sock".
Is this just a bug in how the logs reports the problem or is Traefik actually looking for the daemon at the old endpoint?
Immediately after Traefik reads traefik.toml:
time="2019-06-16T18:33:10Z" level=info msg="Starting provider *docker.Provider {\"Watch\":true,\"Filename\":\"\",\"Constraints\":null,\"Trace\":false,\"TemplateVersion\":2,\"DebugLogGeneratedTemplate\":false,\"Endpoint\":\"unix:///var/run/docker.sock\",\"Domain\":\"\",\"TLS\":null,\"ExposedByDefault\":true,\"UseBindPortIP\":false,\"SwarmMode\":false,\"Network\":\"\",\"SwarmModeRefreshSeconds\":15}"
Error that repeats:
time="2019-06-16T18:33:11Z" level=error msg="Failed to retrieve information of the docker client and server host: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"
time="2019-06-16T18:33:11Z" level=error msg="Provider connection error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, retrying in 676.457252ms"
traefik.toml config:
[docker]
endpoint = "tcp://localhost:2375"
domain = "my.domain"
I've tried changing the endpoint to the local IP of the host machine as well as the Docker network IP but all result in the same error.
Everything works fine as long as /var/run/docker.sock is mounted in the container (regardless of what the endpoint in traefik.toml is) but as soon as I remove it, I started getting the above errors.

SSL springboot Verify the connector's configuration

I want to use ssl in my springboot app. I use this tutorial but when I try up start my app gives me this error:
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8443 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8443, or configure this application to listen on another port.
And my application.properties
#ssl
server.port=8443
server.ssl.key-alias=alias
server.ssl.key-password=password
server.ssl.key-store=classpath:keystore.jks
server.ssl.key-store-provider=SUN
server.ssl.key-store-type=JKS
Or do you know another way to do SSL trusted?
Generate the key with command line running in admin mode.

SailsJS on production - Error: listen EADDRINUSE

I have a VPS server with CentOS and Apache server.
But I want to run my node.js applications too. I am using sails.js
This sails application is trying to listen to port 80 of specified host.
Here is error (after sails lift running):
debug: Starting server in /var/www/user/data/nodeprojects/projectname...
info - socket.io started
debug: Restricting access to host: projectname.com
warn - error raised: Error: listen EADDRINUSE
warn:
warn: Server doesn't seem to be starting.
warn: Perhaps something else is already running on port 80 with hostname projectname.com?
What is the problem? Can I run both apache and nodejs servers on one server with one port (80)?
No, you cannot.
When a server process opens a TCP port to answer requests, it has exclusive use of that port. So, you cannot run both SailsJS and Apache servers on the same port.
Having said that, you can do lots of interesting things with Apache, such as proxying specific requests to other servers running on different ports.
A typical setup would have Apache on port 80 and SailsJS on port 8000 (or some other available port) where Apache would forward requests to certain URLs to SailsJS and then forward the reply from SailsJS back to the browser.
See either configuring Apache on Mountain Lion proxying to Node.js or http://thatextramile.be/blog/2012/01/hosting-a-node-js-site-through-apache for example implementations of this approach.
you cannot use same port for different application. NodeJS can use any open port. What you need todo is port forwarding for your app. :)