Eric Lee
Eric Lee

Reputation: 710

how to port forward to multiple local servers?

I have purchased a server in my office to setup multiple web services like gitlab, odoo, elastic search something like this.

and I want to access multiple web services from externally.

So far what I've tried to do is

  1. installed Ubuntu 16.04 and nginx on the server
  2. setup port-forward from 80 to the server ip in my router
  3. setup DNS for a domain local.example.com to my public IP address so that when I type local.exmaple.com, it redirects to the nginx web server in the server.
  4. appended some strings to the file at /etc/nginx/site-available/default below

    server {
    
        server_name local.example.com;
        listen 80;
        location / {
                proxy_pass http://192.168.0.11:8081;//virtual web server made by virtual box
                proxy_set_header Host $http_host;
                proxy_set_header X-Real_IP $remote_addr;
        }
    }
    

However, after all this stuff, when I type domain name on the browser, it shows nginx web page which is installed on a server not forwarding to virtual host.

Upvotes: 1

Views: 1378

Answers (1)

Tarun Lalwani
Tarun Lalwani

Reputation: 146510

Remove the default server block and restart nginx also. Try after that. Make sure to test in a private window with no caching

The issue is that when you have some mistake in virtual host name or something else, nginx will silently send the request to first server block defined. Or the one set with default server. So you always want to avoid that

Upvotes: 2

Related Questions