From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

start webserver in different folder

Solved!
Go to solution

I've developed a compiled VI (Smarts-Net.exe) that was built to run in a specific folder (\Smarts-Net), and enabled the webserver to show the Smarts-Net.html page in that same folder.  So far, so good.

The application received real-time data generated from another of our programs and generates graphics to show 'what's going on'.

 

My customers would like to run multiple instances of my program for their customers, but want to isolate their Customer 'A' from Customer 'B' so that they can't view each other's data.  I can start up my applicaiton using different IP ports so that I can have multiple views, but I'd like to further isolate the end-customer's data into different folders.

 

I've made a 'manager' program that will create a sub-folder from my main application's folder (\Smarts-Net) so that it would appear like '\Smarts-Net\JobA', and copies all files from the main folder into the new sub-folder.  I then modify the Smarts-Net.ini file with the new folder path and the new port number like this:

[Smarts-Net]
server.app.propertiesEnabled=True
server.ole.enabled=True
server.tcp.servic="My Computer/VI Server"
server.vi.propertiesEnabled=True
WebServer.DirectoryIndex="index.htm"
WebServer.LogEnabled=True
WebServer.LogPath=C:\Smarts-Net\Logs\Smarts-Net.log
WebServer.MimeTypes= (LOTS of Mime types in here ... I left out for this post)
WebServer.Port=9501
WebServer.Enabled=True
WebServer.RootPath=C:\Smarts-Net\JobA
WebServer.TcpAccess="c+*"
WebServer.ViAccess="+*"
DebugServerEnabled=False
DebugServerWaitOnLaunch=False

 

After modifying the .ini file, I start up the application (Smarts-Net.exe) from the new folder.

 

This is where I need some help.  If I try to view the VI from another computer using an address like http://snape:9600/JobA/Smarts-Net.html, I get a 'HTTP 404 - File not found' error.  But, if I try it at http://snape:9600/Smarts-Net.html, I get the VI's panel!

 

So, it appears that I can change the Port in the .ini file, but not the RootPath.  Does anyone know of a way to get the html to load from a different folder than the one specified when I built the application?

0 Kudos
Message 1 of 7
(3,154 Views)
Solution
Accepted by topic author Steve257

Hello Steve,

 

From your description it sounds like the web server is already doing what you say you needed it to.

 

There is a difference between the URL path, path that is entered into the browser, and the filesystem path, the location of the file on disk.

 

The WebServer.RootPath token specifies the directory on the filesystem that will correspond to the root directory, '/', in the URL. You specified C:\Smarts-Net\JobA as your root path so any files in that directory will have the URL of http://mycomputer:myport/myFile. If you wanted the URL of http://mycomputer:myport/JobA/myFile then you would have to make your root directory C:\Smarts-Net\.

 

Does this make sense?

 

Nathan

0 Kudos
Message 2 of 7
(3,142 Views)

Thanks Nathan, it DOES make sense now that you've described it!

 

I was over-thinking myself by changing the RootPath!  By having my manager program leave the .RootPath unchanged (it's C:\Smarts-Net in the original folder), and ONLY changing the .Port, it works exactly as I wanted!

 

You saved me having to develop a method of password protecting each individual end user company!

 

Thanks again.

0 Kudos
Message 3 of 7
(3,137 Views)

I'm very glad if I was helpful.

 

A word of caution:

 

Nothing we have talked about here is a security mechanism. If you have two web servers on different ports they will still be available to anyone. In fact if they serve up the same document root then all web pages will be available at either port. Don't count on this as a way to keep one customer from accessing another customer's pages.

 

For example:

Lets say you set up one instance of your application for customer A. The document root is C:\Smarts-Net. The URL to customer A's page is http://computer:APort/jobA/A'sPage.html.

Customer B also has a separate instance of the application but it us using the same document root, C:\Smarts-Net. Customer B's URL is http://computer:BPort/jobB/B'sPage.html.

 

You have two web servers running on two different ports but since they are serving the same document root all the same pages are available. Customer A could navigate to the URL http://computer:APort/jobB/B'sPage.html.

 

If you really need security you will have to setup something a little more sophisticated than just using a different port.

 

Nathan

Message Edited by NathanK on 02-19-2009 02:02 PM
0 Kudos
Message 4 of 7
(3,128 Views)

Yeah, I'd thought of that too...

 

The individual Customer's Folders are set up in my 'manager' program, and I'm suggesting (but don't have a good way of enforcing yet) that my customer set them up with somewhat ramdomized folder names, so that CustomerA's folder might be CustomerAjas0984m making it much harder for Customer B to guess it.  Not foolproof but bettern than nothing.

0 Kudos
Message 5 of 7
(3,121 Views)

In this thread, you used a couple of keywords that I'm very interested in.  I'm wondering if you were able to get this working, and if you'd mind sharing a little bit of code.  I have a client/server setup now where the client connects securely to the server (TLSv1) using an ActiveX, Internet Explorer, IWebBrowser2.  I then send messages to the radio (UUT) via the Navigate2 method.  I have to build MIME-formatted messages (in a couple of cases) due to having to send some Excel and .txt files.  This is extremely cumbersome, but necessary since Navigate2 doesn't put it all together for you.  If fact, the documentation is so poor, I have no idea what is absolutely mandatory when trying to build MIME in this fashion. 

 

Anyway, I notice you have a .Net application, and that you mentioned MIME.  I'm wondering if what I'm doing can be done with .Net instead of ActiveX and if the MIME support is more robust in .Net.  Any help on this would be extremely appreciated.

0 Kudos
Message 6 of 7
(2,793 Views)
Actually, this isn't a .Net application...the name of the program (and folder) is Smarts-Net (-Net, not .Net).  Sorry, but I've no words of wisdom for you.
0 Kudos
Message 7 of 7
(2,773 Views)