Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2014
    Posts
    44

    Can someone validate my nginx reverse proxy config

    Hi guy's, i made my reverse proxy config and want to know if i made any mistake from what i have learn so far :

    server {
    listen 80;
    server_name www.website01.com;

    location / {
    proxy_pass http://www.website01.com;
    }

    server {
    listen 80;
    server_name http://www.website02.com;

    location / {
    proxy_pass http://www.website01.com;
    }

    server {
    listen 80;
    server_name http://www.website03.com;

    location / {
    proxy_pass http://www.website01.com;
    }

    Regards Peter

  2. #2
    Join Date
    Jul 2005
    Location
    here, there, where?
    Posts
    4,102
    1. server_name should only be the server address, not including http://
    2. You are creating a infinite proxy - nginx will connect to it self - you need the proxy pass to use the backend server port. The proxy_pass needs to be
    Code:
    proxy_pass http://www.website01.com:backend_server_port;
    When using a reverse proxy, nginx or otherwise, traffic comes in to nginx and is expected to then go to a backend server. That backend server could be apache, IIS, an app container, etc that responds to http calls. Nginx as a proxy acts a dispatcher / director of traffic to the actual app / service. Browser -> nginx -> backend server -> nginx -> browser.
    -Steven | Cooini, LLC
    "It is the mark of an educated mind to be able to entertain a thought without accepting it" -Aristotle

  3. #3
    Join Date
    Jul 2014
    Posts
    44
    Quote Originally Posted by steven99 View Post
    1. server_name should only be the server address, not including http://
    2. You are creating a infinite proxy - nginx will connect to it self - you need the proxy pass to use the backend server port. The proxy_pass needs to be
    Code:
    proxy_pass http://www.website01.com:backend_server_port;
    When using a reverse proxy, nginx or otherwise, traffic comes in to nginx and is expected to then go to a backend server. That backend server could be apache, IIS, an app container, etc that responds to http calls. Nginx as a proxy acts a dispatcher / director of traffic to the actual app / service. Browser -> nginx -> backend server -> nginx -> browser.
    Hi Steven and again thank for your kind help and patience for my lack of understanding of the reverse proxy concept.

    Everything was going fine on my vps setup until this reverse proxy thing sent me on almost a week of reading and headaches!

    By looking at the code i have post i already notice that i have made big mistake since i am making an endless loop by redirecting the first server block on itself and i also forgive to close brackets because i didn't made clean indentation.

    What put a lot of confusion regarding this topic is that most people using it are using it to redirect to a node.js or an app but i think i haven't see any guides showing it for simple independent websites.

    Maybe i am over doing thing and i don't really need to use a reverse proxy on my vps setup since i am already under ssh and i will also have https/ssl on my server block.

    My only goal is to secure as much as i can my 3 websites with my limited knowledge on server configuration.

    If someone can tell me if i really need a reverse proxy and how to implement it i am eager to learn how to properly do it.

    For all the rest i was OK and didn't have any problem setting up my server block it's only when i got to the reverse proxy thing that i was stuck!

    Regards Peter

  4. #4
    Join Date
    Jul 2005
    Location
    here, there, where?
    Posts
    4,102
    Honestly, I would just advise to use Plesk or other control panels that offer what you need. Dealing with configs can be a pain at times if you are not familiar with them - and sometimes even if you are. If you are using Node.js, Plesk has support for that out of the box. Sure Plesk isn't free but is you time?

    With that said, lets look at the node.js as an example. In the node.js server.listen, you give it a port to use as the first argument:

    Code:
    server.listen(7743)
    So the proxy pass would be come:
    Code:
    proxy_pass http://www.website01.com:7743;
    For each node.js instance, it should have a separate port and you use that port for the proxy pass.

  5. #5
    Join Date
    Jul 2014
    Posts
    44
    Quote Originally Posted by steven99 View Post
    Honestly, I would just advise to use Plesk or other control panels that offer what you need. Dealing with configs can be a pain at times if you are not familiar with them - and sometimes even if you are. If you are using Node.js, Plesk has support for that out of the box. Sure Plesk isn't free but is you time?

    With that said, lets look at the node.js as an example. In the node.js server.listen, you give it a port to use as the first argument:

    Code:
    server.listen(7743)
    So the proxy pass would be come:
    Code:
    proxy_pass http://www.website01.com:7743;
    For each node.js instance, it should have a separate port and you use that port for the proxy pass.
    Hi again Steven and unfortunately since i am on disability without any insurance i can barely making it from month to month so paid solution for the moment are impossible but once my game is on sale thing may get better and i would probably hire a professional to do so since the game dedicated server is surely way too complicated for me to handle.

    Thank for the example with node.js but i wont need anything like this, i was only trying to set this reverse proxy to get better security for my 3 websites host on same vps.

    Regards Peter

  6. #6
    Join Date
    Jul 2014
    Posts
    44

    I made a diagram about how i see it

    I made a diagram to explain the way i am understanding the reverse proxy thing, i don't know if it make sense but if so what would the reverse proxy config would look like, for me i see it this way here :

    In the example i am thinking as the vps main server to be like a fake server only displaying the welcome to nginx and all other websites pointing to it. The goal is to hide the 3 websites from prying eye but again i am probably wrong with this idea.

    https://imgur.com/GkIVvaL

    Code:
    server {
    listen 80;
    server_name  www.website01.com;
    
    }
    
    server { 
    listen 80; 
    server_name  www.website01.com;
    }
    location / {
    proxy_pass 118.233.1.1;
    }
    
    server { 
    listen 80; www.website02.com;
    }
    location / {
    proxy_pass 118.233.1.1;
    }
    
    server {
    listen 80;
    server_name www.website03.com;
    }
    location / {
    proxy_pass 118.233.1.1;
    }
    Regards peter

Similar Threads

  1. Can someone help me understand reverse proxy with nginx
    By pixelquaternion in forum Web Hosting
    Replies: 6
    Last Post: 08-24-2022, 09:11 PM
  2. Replies: 0
    Last Post: 10-02-2019, 03:45 AM
  3. Can I setup an nginx reverse proxy alongside cPanel?
    By Mentorforums in forum Dedicated Server
    Replies: 7
    Last Post: 03-31-2013, 12:42 PM
  4. Will my nginx reverse proxy cache work?
    By Akufoo in forum Web Hosting
    Replies: 3
    Last Post: 09-23-2012, 12:33 AM
  5. Replies: 1
    Last Post: 04-05-2001, 10:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •