Rozukai
Rozukai
RRailway
Created by Rozukai on 1/17/2024 in #✋|help
Access project data inside of a railway service
Hi everyone, Do you know if there is a way to access railway data from within a railway service? Or is it necessary to access it through the API using ProjectID and API Token as environment variables? My question is more about security, specifically to prevent a malicious user from being able to change environment variables and corrupt the system.
5 replies
RRailway
Created by Rozukai on 1/17/2024 in #✋|help
cURL issue at start
Hi, I got a script that call another service to init some var environement like this :
#!/usr/bin/env bash

if [ -z "$TOKEN_PROVIDER_ADDR" ]; then
echo "TOKEN_PROVIDER_ADDR environment variable is not set"
exit 1
fi

sleep 20

# API URL
PROVIDER_API_URL=$TOKEN_PROVIDER_ADDR/token/provide

echo "Fetching key from $PROVIDER_API_URL"

# Fetch the token
TOKEN=$(curl -s -v $PROVIDER_API_URL)

echo "Key: $TOKEN"

# Check if the key is retrieved successfully
if [ -z "$KEY" ]; then
echo "Failed to fetch key from API"
exit 1
fi

# Export the key as an environment variable
export TOKEN=$TOKEN

# Run your application
/app
#!/usr/bin/env bash

if [ -z "$TOKEN_PROVIDER_ADDR" ]; then
echo "TOKEN_PROVIDER_ADDR environment variable is not set"
exit 1
fi

sleep 20

# API URL
PROVIDER_API_URL=$TOKEN_PROVIDER_ADDR/token/provide

echo "Fetching key from $PROVIDER_API_URL"

# Fetch the token
TOKEN=$(curl -s -v $PROVIDER_API_URL)

echo "Key: $TOKEN"

# Check if the key is retrieved successfully
if [ -z "$KEY" ]; then
echo "Failed to fetch key from API"
exit 1
fi

# Export the key as an environment variable
export TOKEN=$TOKEN

# Run your application
/app
But I got this error :
Fetching key from http://xxx.railway.internal:8000/token/provide
* Host xxx.railway.internal:8000 was resolved.
* IPv6: fd12:e63e:8590::80:9c86:bbc9
* IPv4: (none)
* Trying [fd12:e63e:8590::80:9c86:bbc9]:8000...
* connect to fd12:e63e:8590::80:9c86:bbc9 port 8000 from fd12:e63e:8590::92:8458:6384 port 38030 failed: Connection refused
* Failed to connect to xxx.railway.internal port 8000 after 3 ms: Couldn't connect to server
* Closing connection
Key:
Failed to fetch key from API
Fetching key from http://xxx.railway.internal:8000/token/provide
* Host xxx.railway.internal:8000 was resolved.
* IPv6: fd12:e63e:8590::80:9c86:bbc9
* IPv4: (none)
* Trying [fd12:e63e:8590::80:9c86:bbc9]:8000...
* connect to fd12:e63e:8590::80:9c86:bbc9 port 8000 from fd12:e63e:8590::92:8458:6384 port 38030 failed: Connection refused
* Failed to connect to xxx.railway.internal port 8000 after 3 ms: Couldn't connect to server
* Closing connection
Key:
Failed to fetch key from API
I've just changed the host name by xxx for privacy purpose.
16 replies
RRailway
Created by Rozukai on 1/16/2024 in #✋|help
There is a way to update automatically env var when deploying ?
Hi, Do you know if there is a way to update env var before running the auto deployment by Github push ? I see that their is an API but request it every minutes is not very a good practice. Do you know if there is a solution ?
5 replies
RRailway
Created by Rozukai on 12/19/2023 in #✋|help
Error while connecting to database through private network
Hi everyone, I just migrate my postgres database and thus change some environment variable. I've set my database url to "postgres.railway.internal" as host but I got this error when running my app :
failed creating schema resources: querying server version dial tcp: lookup postgres.railway.internal on 8.8.8.8:53: no such host
failed creating schema resources: querying server version dial tcp: lookup postgres.railway.internal on 8.8.8.8:53: no such host
Do you know why ? Have a good say 😉
16 replies
RRailway
Created by Rozukai on 12/19/2023 in #✋|help
Namecheap SMTP return error
Hi everyone, In my golang app, I try to connect to namecheap private email service using the specified settings here : https://www.namecheap.com/support/knowledgebase/article.aspx/1179/2175/general-private-email-configuration-for-mail-clients-and-mobile-devices/ But I got this error : 2023/12/19 15:05:59 read tcp 172.17.2.105:50178->198.54.122.135:465: read: connection reset by peer Here is my golang code :
emailTemplate, _ := template.ParseFiles(fmt.Sprintf("%s/%s", useCase.templateSettings.TemplatePath, "sign-in.email.html"))

var body bytes.Buffer

mimeHeaders := "MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n"
body.Write([]byte(fmt.Sprintf("Subject: Verify your email \n%s\n\n", mimeHeaders)))
err = emailTemplate.Execute(&body, struct {
Callback string
}{
Callback: fmt.Sprintf("%s?email=%s&uniqId=%s", useCase.verifyEmailSettings.CallbackBaseUrl, message.Email, uniqId.String()),
})
if err != nil {
return errors.NewInternalError("Error while sending verification email", err)
}

smtpAuth := smtp.PlainAuth("", useCase.smtpSettings.Username, useCase.smtpSettings.Password, useCase.smtpSettings.Host)
err = smtp.SendMail(useCase.smtpSettings.Host+":"+useCase.smtpSettings.Port, smtpAuth, useCase.smtpSettings.Username, []string{message.Email}, body.Bytes())
if err != nil {
return errors.NewInternalError("Error while sending verification email", err)
}
emailTemplate, _ := template.ParseFiles(fmt.Sprintf("%s/%s", useCase.templateSettings.TemplatePath, "sign-in.email.html"))

var body bytes.Buffer

mimeHeaders := "MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n"
body.Write([]byte(fmt.Sprintf("Subject: Verify your email \n%s\n\n", mimeHeaders)))
err = emailTemplate.Execute(&body, struct {
Callback string
}{
Callback: fmt.Sprintf("%s?email=%s&uniqId=%s", useCase.verifyEmailSettings.CallbackBaseUrl, message.Email, uniqId.String()),
})
if err != nil {
return errors.NewInternalError("Error while sending verification email", err)
}

smtpAuth := smtp.PlainAuth("", useCase.smtpSettings.Username, useCase.smtpSettings.Password, useCase.smtpSettings.Host)
err = smtp.SendMail(useCase.smtpSettings.Host+":"+useCase.smtpSettings.Port, smtpAuth, useCase.smtpSettings.Username, []string{message.Email}, body.Bytes())
if err != nil {
return errors.NewInternalError("Error while sending verification email", err)
}
SMTP connexion can be done on Railway ?
12 replies
RRailway
Created by Rozukai on 9/27/2023 in #✋|help
DNS error on bucket S3
Hi everyone, I've just deploy the template to automate postgresql backups and I got this error when the script try to deploy the backup :
Error while running backup: Error: getaddrinfo EAI_AGAIN ******.s3.us-west-3.amazonaws.com
Error while running backup: Error: getaddrinfo EAI_AGAIN ******.s3.us-west-3.amazonaws.com
Do you know why I got this error ? Have a good day
38 replies
RRailway
Created by Rozukai on 9/8/2023 in #✋|help
Enabled mlock
No description
8 replies
RRailway
Created by Rozukai on 8/31/2023 in #✋|help
vm.max_map_count [65530] is too low during deployement
No description
21 replies