9 months ago
Was able to configure both spring boot service and postgresql service inside Railway. But even specifying the PORT variable, I can't reach the app by the url generated. In my browser I keep receiving ERR_TOO_MANY_REDIRECTS page.
This service was migrated from Heroku, I had to adapt few variables but the deploy seem to worked.
What am I missing???
I'm using spring boot with java 21.
This is my railway.json file, most of variables informed are to run within the 512mb of the free plan and the other are for Hazelcast work in Java 9 and above.
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"runtime": "V2",
"numReplicas": 1,
"startCommand": "java --enable-preview -jar -Dspring.profiles.active=prod -XX:+UseSerialGC -Xss512k -XX:MaxRAMPercentage=75 -Xmx384m -Xms256m -XX:+PrintGCDetails -Xloggc:gc.log --add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED target/*.jar",
"sleepApplication": true,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
This is the lattest log confirming the success of application deploy.
Starting ProtocolHandler ["http-nio-8080"]
Tomcat started on port 8080 (http) with context path '/'
Started SarneyAmorimApplication in 23.394 seconds (process running for 24.351)
Initializing Spring DispatcherServlet 'dispatcherServlet'
Initializing Servlet 'dispatcherServlet'
Completed initialization in 1 ms
5 Replies
9 months ago
This is the current url configured inside railway: https://sarneyamorim.up.railway.app/
9 months ago
I'm getting ERR_TOO_MANY_REDIRECTS
Is your app trying to do some kind of secure ssl redirect?
9 months ago
I don't think so Brody, can't say for sure. But as I said, I was using Heroku with the exact same configuration.
At my server, I'm logging every request that reaches the application. Looking the log here, there isn't no logging at all after initialization.
9 months ago
I think I fix the problem:
I use spring boot security, at defaultSecurityFilterChain method I was using a configuration to enforce HTTPS requests for every request that had "X-Forwarded-Proto" header.
Commenting those lines, the app got requests:
// .requiresChannel((requiresChannel) ->
// requiresChannel.requestMatchers(r -> r.getHeader("X-Forwarded-Proto") != null)
// .requiresSecure()
// )
Status changed to Solved brody • 9 months ago