Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8389313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:41:36+00:00 2026-06-09T18:41:36+00:00

I have 2 Rails apps running on the same server. I want requests to

  • 0

I have 2 Rails apps running on the same server. I want requests to domain1.com to get forwarded to my Rails1 app, and the domain2.com requests to my Rails2 app. I configured my nginx.conf like so:

upstream thin1 {
    server 0.0.0.0:3000;
    server 0.0.0.0:3001;
    server 0.0.0.0:3002;
}

upstream thin2 {
    server 0.0.0.0:3003;
    server 0.0.0.0:3004;
    server 0.0.0.0:3005;
}

server {
    listen          80;
    server_name     *.domain1.com;
    root            /path1/;        

    location / {
        try_files $uri/index.html $uri.html $uri @backend;
    }

    location @backend {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://thin1;
    }   
}

server {
    listen                  80;
    server_name             *.domain2.com;
    root                    /path2/;

    location / {
        try_files $uri/index.html $uri.html $uri @backend;
    }

    location @backend {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://thin2;
    }   
}

But all requests (domain1.com and domain2.com) get forwarded to my Rails1 app. Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:41:38+00:00Added an answer on June 9, 2026 at 6:41 pm

    using 2 different names for your named locations should fix it:

    location @backend1 {
      proxy_set_header  X-Real-IP  $remote_addr;
      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://thin1;
    }
    
    location @backend2 {
      proxy_set_header  X-Real-IP  $remote_addr;
      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://thin2;
    }
    

    (don’t forget to change the try_files directive of each server accordingly)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get my server to serve my rails apps. I have a test
I'm installing a new server for run Rails apps, I already have 1 app
I've managed to get a Rails app deployed with Capistrano to a server running
I would like to have individuals config for my rails apps on my server,
I have rails application running in linode server .Some guy is continuously spamming (writing
If I have a Ruby on Rails application running on my Apache shared server
I have been trying to get a ruby on rails app going on my
I have a Rails 3.1 app running in production using Nginx and Unicorn. And
I have a rails application running on my shared host server and the public_html
I am running Win7 and have created Rails 3 apps on this box and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.