Private network for apps to website
mathebp1
HOBBYOP

7 months ago

I have my website on my git repo which i've imported into Railway and have setup this to link to my website domain name via Cloudflare.

I have a number of python Flask apps that I want to import into Railway and have links to these on my website.

I've setup a test app to try get the private network running beween the Railway website and test app, but it doesnt seem to work.

Website code rerouting to internal network:

/** @type {import('next').NextConfig} */
const nextConfig = {
  async rewrites() {
    return [
            {
        source: '/test-counter/:path*',
  destination: 'http://test.railway.internal:8080/:path*',
      }
    ];
  },
};

module.exports = nextConfig;

application below linking to 8080 port.

from flask import Flask, render_template, jsonify
from werkzeug.middleware.proxy_fix import ProxyFix
import os


app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_port=1, x_prefix=1)

# In-memory counter
counter = {"value": 0}

@app.route("/")
def index():
    return render_template("index.html")

@app.route("/api/increment", methods=["POST"])  # increment the counter
def increment():
    counter["value"] += 1
    return jsonify(counter)

@app.route("/api/value")  # fetch current value
def value():
    return jsonify(counter)

if __name__ == "__main__":
    import os
    port = int(os.environ.get("PORT", 8080))
    # Bind to IPv6 (and it will also accept IPv4 via IPv4-mapped addresses)
    app.run(host="::", port=port)
$10 Bounty

1 Replies

Railway
BOT

7 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


Loading...