fix: renamed rts port env to APPSMITH_RTS_PORT (#20121)

Issue: Nginx and RTS used the same env PORT for binding it's service,
while the backend server had the rts port hardcoded on its rts uri.
- Renamed env PORT to APPSMITH_RTS_PORT for starting the rts server.
- Updated nginx config templates to use env `APPSMITH_RTS_PORT`
- Added appsmith.rts.port property in server to use env
APPSMITH_RTS_PORT
- Updated CommonConfig.java rtsBaseDomain to use appsmith.rts.port

---------

Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
This commit is contained in:
Sumesh Pradhan 2023-02-15 07:06:02 +05:30 committed by GitHub
parent 0097c0f450
commit a846bd4952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 10 deletions

View File

@ -35,7 +35,7 @@ if (API_BASE_URL == null || API_BASE_URL === "") {
process.exit(1); process.exit(1);
} }
const PORT = process.env.PORT || 8091; const APPSMITH_RTS_PORT = process.env.APPSMITH_RTS_PORT || 8091;
//Disable x-powered-by header to prevent information disclosure //Disable x-powered-by header to prevent information disclosure
const app = express(); const app = express();
@ -62,8 +62,8 @@ app.use(`${RTS_BASE_API_PATH}`, health_check_routes);
server.headersTimeout = 61000; server.headersTimeout = 61000;
server.keepAliveTimeout = 60000; server.keepAliveTimeout = 60000;
// Run the server // Run the server
server.listen(PORT, () => { server.listen(APPSMITH_RTS_PORT, () => {
log.info(`RTS version ${buildVersion} running at http://localhost:${PORT}`); log.info(`RTS version ${buildVersion} running at http://localhost:${APPSMITH_RTS_PORT}`);
}); });
export default server; export default server;

View File

@ -64,7 +64,8 @@ public class CommonConfig {
@Value("${disable.telemetry:true}") @Value("${disable.telemetry:true}")
private boolean isTelemetryDisabled; private boolean isTelemetryDisabled;
private String rtsBaseDomain = "http://127.0.0.1:8091"; @Value("${appsmith.rts.port:8091}")
private String rtsPort;
private List<String> allowedDomains; private List<String> allowedDomains;
@ -128,5 +129,8 @@ public class CommonConfig {
// If `true`, then disable signup. If anything else, including empty string, then signups will be enabled. // If `true`, then disable signup. If anything else, including empty string, then signups will be enabled.
isSignupDisabled = "true".equalsIgnoreCase(value); isSignupDisabled = "true".equalsIgnoreCase(value);
} }
public String getRtsBaseUrl() {
return "http://127.0.0.1:" + rtsPort;
}
} }

View File

@ -149,7 +149,7 @@ public class InstanceConfig implements ApplicationListener<ApplicationReadyEvent
log.debug("Performing RTS health check of this instance..."); log.debug("Performing RTS health check of this instance...");
return WebClientUtils return WebClientUtils
.create(commonConfig.getRtsBaseDomain() + "/rts-api/v1/health-check") .create(commonConfig.getRtsBaseUrl() + "/rts-api/v1/health-check")
.get() .get()
.retrieve() .retrieve()
.toBodilessEntity() .toBodilessEntity()

View File

@ -75,7 +75,7 @@ public class AstServiceCEImpl implements AstServiceCE {
} }
return webClient return webClient
.post() .post()
.uri(commonConfig.getRtsBaseDomain() + "/rts-api/v1/ast/multiple-script-data") .uri(commonConfig.getRtsBaseUrl() + "/rts-api/v1/ast/multiple-script-data")
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(new GetIdentifiersRequestBulk(bindingValues, evalVersion))) .body(BodyInserters.fromValue(new GetIdentifiersRequestBulk(bindingValues, evalVersion)))
.retrieve() .retrieve()
@ -102,7 +102,7 @@ public class AstServiceCEImpl implements AstServiceCE {
EntityRefactorRequest entityRefactorRequest = new EntityRefactorRequest(bindingValue.getValue(), oldName, newName, evalVersion, isJSObject); EntityRefactorRequest entityRefactorRequest = new EntityRefactorRequest(bindingValue.getValue(), oldName, newName, evalVersion, isJSObject);
return webClient return webClient
.post() .post()
.uri(commonConfig.getRtsBaseDomain() + "/rts-api/v1/ast/entity-refactor") .uri(commonConfig.getRtsBaseUrl() + "/rts-api/v1/ast/entity-refactor")
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(entityRefactorRequest)) .body(BodyInserters.fromValue(entityRefactorRequest))
.retrieve() .retrieve()

View File

@ -110,3 +110,6 @@ appsmith.admin.envfile=${APPSMITH_ENVFILE_PATH:/appsmith-stacks/configuration/do
# Name of this instance # Name of this instance
appsmith.instance.name=${APPSMITH_INSTANCE_NAME:Appsmith} appsmith.instance.name=${APPSMITH_INSTANCE_NAME:Appsmith}
# RTS port
appsmith.rts.port=${APPSMITH_RTS_PORT:8091}

View File

@ -91,7 +91,7 @@ server {
} }
location /rts { location /rts {
proxy_pass http://localhost:8091; proxy_pass http://localhost:${APPSMITH_RTS_PORT:-8091};
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Host \$host; proxy_set_header Host \$host;
proxy_set_header Connection 'upgrade'; proxy_set_header Connection 'upgrade';

View File

@ -108,7 +108,7 @@ server {
} }
location /rts { location /rts {
proxy_pass http://localhost:8091; proxy_pass http://localhost:${APPSMITH_RTS_PORT:-8091};
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Host \$host; proxy_set_header Host \$host;
proxy_set_header Connection 'upgrade'; proxy_set_header Connection 'upgrade';