Temporary test domain name or way to achieve this

June 19, 2017 95 views
LEMP Ubuntu 16.04

I created a multi install with a single website and was able to do that because there was a working IP address.
Now I have 1 site there however I can't use the ip address (or can I) to go to the NEW folder for the new site to test.
In previous hosting scenarios I was able to turn on what was called a testing url which gave access to a folder. I tried this in my sites-available block..rewrite ^$ var/www/ redirect;
This didn't work as the old site just 404'd

I have also tried to edit the /sites-available/digitalocean file which as I understand is the default from my one click install of LEMP. So I thought this could be the file the dedicated IP address could root through I pointed the root directive to my new sites folder of that but it didn't do anything and I still get to my initial website.

How to achieve this?

3 Answers

Out of interest what operating system are you using locally on your own computer?

If you're using Windows you can edit the file C:\Windows\System32\drivers\etc\hosts and add a line like this:

Replace with the IP address of your droplet. will then map to your droplet from your local work station, bypassing any external DNS lookup.

Setup a new virtual host under sites-enabled.conf for and away you go.

  • I am using a mac.
    Yes I thought about my local hosts file but as I understand it this just allows me to access my droplet with a local custom domain.
    I have no problem accessing the droplet through the I missing something?
    What I think or feel I need is a way to access the NEW FOLDER.
    I am not sure what makes the 'digitalocean' inside sites-available as the default but would think I could use that to point to my new site folder.
    Thanks for this insight :)

    • In /etc/apache2/sites-available you should have a file called something like which will contain the virtual host for that domain, i.e.:

      <VirtualHost *:80>
      DocumentRoot /var/www/

      Create a new file in /etc/apache2/sites-available called or similar with the following contents:

      <VirtualHost *:80>
      DocumentRoot /var/www/

      However, if you want to show the virtual host for you could redirect it:

      <VirtualHost *:80>
      DocumentRoot /var/www/
      Redirect /newsite

      If you don't want to redirect it but actually want it to show under, I'm not sure how you do that with mod_rewrite. What you want to do is rewrite the URL to a different virtualhost - I'm not sure how you do this or if you have to use some kind of proxypass configuration, but it seems complicated for what you require.

      • Thanks again - yes this is the kind of thing that could work. I didn't mention I was using NGINX though but principle could be the same so this redirect needs to redirect to a local folder hence..

        rewrite ^$ var/www/ redirect;

        So theory is we use the domain to get to the DO DNS and then it resolves to my droplet. At this point the redirect should work to redirect to the local folder (other website) but it doesn't catch the redirect it just 404's

        • I think that's because you can't rewrite like that. It has to be relative your document root I believe.

          It will be looking for this folder:


          Which obviously doesn't exist.

          A better option might be to simply create a symbolic link:

          ln -s /var/www/ /var/www/

          • Sorry yes that was a typo missing the "/" in this post.
            Where would I write a symbolic link? Is that part of the nginx config file.

A better option might be to simply create a symbolic link.

A symbolic link is part of your file system (nothing to do with Apache or nginx).

It creates a "virtual" directory which maps to a directory elsewhere in the file system.

You would run this via the command line (make sure the newsite folder doesn't already exist):

ln -s /var/www/ /var/www/

This creates a "vitual" link under /var/www/ which maps to /var/www/

Anyone visiting will see the contents of /var/www/

  • That sounds like a handy workaround but my folder isn't empty and it leaves a bit of confusion for me coming back here say in 6 I would like to get the server blocks right.

In my case what seems to have been lacking is a default server and now it seems to be working and what @DigitalCarrot would have got had I posted my server block code...many thanks to you @DigitalCarrot

SO in my default site block I now have this

server {
        listen 80 default_server;
        listen [::]:80 default_server;


server {
        listen 80;
        listen [::]:80;

Now when I use the IP address remotely I can access what this default site points to...

Have another answer? Share your knowledge.