0

Not sure if this is actually called a proxy Here is what I have:

server {
        listen 80;
        listen mckelvey.me:1122
        server_name mckelvey.me
        location / {
                /personal-website
        }
}

My website is at mckelvey.me:1122 I want my website to be at mckelvey.me. I have no idea how to do this. The ip is 104.131.153.117 and the node application is at /home/deploy than I have a file called deploy.tar that has the website. It runs perfectly at mckelvey.me:1122

heres the bash script I use to deploy my website:

#! /usr/bin/env bash
set -e

remote_deploy_dir=/srv/personal_website

remote_host=mckelvey.me
remote_user=deploy
remote_port=22

echo
echo Compressing codebase for push
tar c -f deploy.tar --exclude deploy.tar .

echo
echo Uploading codebase
scp -P $remote_port deploy.tar $remote_user@$remote_host:.
rm deploy.tar

ssh -T -p $remote_port $remote_user@$remote_host <<END_SSH_COMMANDS
  set -o xtrace
  echo
  echo Creating $remote_deploy_dir
  sudo mkdir -p $remote_deploy_dir
  cd $remote_deploy_dir

  echo
  echo Stopping old site instace
  forever stop index.js || echo no old instance found

  echo
  echo Extracting codebase
  sudo tar xf ~/deploy.tar -C .

  echo
  echo Starting new site instance
  forever start index.js
END_SSH_COMMANDS
5
  • If I need to add anything to this to make it more helpful I can, just comment it or edit. Commented May 9, 2015 at 19:01
  • Can you also provide the configuration of the nodejs application you are trying to setup for reverse proxy? The IP and port it is running on? I want the request at mckelvey.me to hit the nodejs application, right? Commented May 9, 2015 at 19:08
  • @NomanUrRehman Updated question. Hows that? is that what you meant? i also added the bash script that i use to deploy my website. Commented May 9, 2015 at 19:17
  • No. A nodejs application runs independently on your server with an ip and port then you setup an nginx proxy in front of it to redirect requests to your nodejs application. Is this how things are setup at your end? Commented May 9, 2015 at 19:21
  • @NomanUrRehman The nodejs is running on the port 1122 with the ip address of 104.131.153.117 I believe, which go out as mckelvey.me:1122. I am very new to this so bare with me if I am still not understanding. Oh wait it might be port 22, because my bash script: remote_port=22 Commented May 9, 2015 at 19:23

1 Answer 1

3

Here is the Nginx configuration you should have in order to set the reverse proxy up for your Nodejs application:

server {
    listen 80;
    server_name mckelvey.me;
    location / {
        proxy_pass http://104.131.153.117:1122;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.