0

I just installed Nginx as a feature of VestaCP on my VPS.

What I'm trying to do is to mask the URL http://example.com to http://12345.com, so when users visit http://example.com/path/file.mp4 they will see the content of http://12345.com/path/file.mp4 but browsers still show the URL http://example.com/path/file.mp4.

I googled and found a topic here. It looks like the answer I'm looking for. However when I applied his code to nginx.conf, VestaCP showed Error: nginx failed to start with new config and stopped working.

Here is the code:

server {
    listen 80;
    server_name sub.example.com;

    location / {
    proxy_pass https://123.12.12.12;
    rewrite ^/$ /path last;
    }
}

Is this the right solution for me? I'm completely new to this so I don't know if I did it correctly.

Edited: I was able to get the job done using apache .htaccess. How do I convert this to use with Nginx?

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^ http://12345.com%{REQUEST_URI} [L,NE,P]
David Tran
  • 63
  • 1
  • 9

1 Answers1

0

You just need below, no rewrite needed

server {
    listen 80;
    server_name sub.example.com;

    location / {
       proxy_pass https://123.12.12.12;
    }
}
Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265
  • I got this error when trying to save the config file `Error: nginx failed to start with new config` – David Tran Sep 08 '17 at 22:44
  • Run `nginx -t`, there might be some other config also getting loaded. Use `find /etc/nginx -name "*conf*"` to see what all configs are there – Tarun Lalwani Sep 09 '17 at 04:12
  • This is what it shows when I run the command: ` nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful ` – David Tran Sep 09 '17 at 12:22