Domain Forwarding to Perspective

If you are using Perspective for your SCADA system, chances are you are accessing it using an IP Address in a browser. It would look something like this https://192.168.1.110:8043/data/perspective/client/ProjectName.

While that will work perfectly well, unless IT is managing setting up bookmarks for that can be a real mouthful when you need to share the link with someone.

To make life easier you can set up a domain name so you could go to project.corsosystems.com, or even perspectiveproject.com to open your perspective app.

Enter nginx

To get forwarding set up the easiest way is to use nginx. Nginx (pronounced engine X) is an HTTP and reverse proxy server. In basic terms this means it will handle HTTP requests, and also act as a middle layer between the traffic arriving at the server and what we want to access on the server itself. You could accomplish similar functionality using .NET, Apache, or many other options. We’ve found nginx is really easy to get started with.

The first step is to install nginx on the machine where you have Ignition running. In our case it is a Ubuntu server (installation instructions here), you can also use Windows (installation instructions here).

Once you have it installed we’ll need to go into the configuration files and add some options to get everything set up. We’ll first get nginx configured, test it using the machine’s IP address, then we’ll add in the domain configuration after.

Configuration

On Linux the file we are going to use is /etc/nginx/sites-enabled/default and on Windows it would be C:\nginx\conf\sites-enabled\default. Open this file in your text editor of choice, and modify it to look like the following:

server {

    listen 80 default_server;
    listen [::]:80 default_server;
    autoindex_localtime on;
    autoindex on;

    server_name _;

    location /  {
            proxy_pass http://localhost:8088;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            rewrite ^/$ /data/perspective/client/ProjectName permanent;
    }

}

Here we are telling nginx to listen on port 80 for requests hitting the server. The autoindex lines help manage the time shown in Perspective apps. The location is set to a / which is simply looking at the IP address of the server, or the URL without anything after the .com. If we want to do something like perspectiveproject.com/blogpost we could do something different with that URL compared to perspectiveproject.com like we are doing here.

The proxy settings are used to convert the URL nginx is seeing the request come in on and proxying it to the _pass URL, in this case the URL of Ignition running on this machine. The next 3 lines handle the websockets used by Perspective, and the rewrite line allows us to rewrite the URL to include the information after the / in the URL we need to get into the Perspective project itself.

Now you should be able to type in the IP Address of your server in a browser and see the Perspective application loaded with the correct URL.

Next we want to forward the domain.

Domain Forwarding

To forward a domain you will first need to get access to one. In our case we typically use GoDaddy.com for this. You can search your domain and see if it is available, and purchase it. Your may use a different hosting provider or domain registrar, regardless the concept will be the same.

Once you have the domain you will want to go into the DNS Settings and set up an A Record to point to the IP Address of your server. The name value will be @ and the value will be the IP Address of your server. Once you save these changes you might have to wait a bit to see it populate, but now you can type in your domain in a browser and see the project load.

Wrapping Up

You can go a whole lot deeper with nginx. Subdomains, load balancing configuration, doing more complex re-writes, etc. There are a lot of good resources for configuring nginx for just about anything you might need it to do for you, we have barely scratched the surface here.

If you have any questions or want help navigating nginx to get your Perspective projects online please reach with the button below!

Previous
Previous

ICC 2021 Recap

Next
Next

Ignition Script Console