URL for a resource located on the local machine in REST ROA - rest

This question is in terms of a RESTful ROA (Resource-Oriented Architecture). A resource on the Web has a URL (or URI if you prefer), for instance http://myserver.com/me.jpg.
You can get a file on the local (Windows) machine like this: file:///C:/MyPictures/me.jpg. This is not exactly a "Universal" Resource Identifier; it doesn't work right if you try it on a different machine. On your machine this may be a picture of you instead of me.
Suppose I want to design an application where files can be copied to a web service. Other users on other machines can download them from the web service, but if you are using it from the original machine they are fetched from the local file system for speed.
Is there any concept of a URI that refers to a file on a particular machine if it happens to be the local machine? Is there any concept of a URI for a particular machine? IP address isn't enough; my machine's IP address is 192.168.0.102 and yours may be too.
I would like to store a number of locations for the photo as first choice, second choice etc. First choice = file:///C:/MyPictures/me.jpg but only if the local machine is the machine it came from; second choice = http://myserver.com/me.jpg.
Another way of stating the same question: this machine is unique, and the file at C://somedir/somefile.jpg is unique. Does it have a unique address? An address that would yield either "No Route to Host" or the correct file, depending on where you requested it from?

Is there any concept of a URI that
refers to a file on a particular
machine if it happens to be the local
machine?
Let's follow the logic. How is this to be determined? The URI absolutely must contain a name which uniquely identifies the machine.
Hence, your machine must be identified by a publicly registered name. You have clearly identified that a private IP address is insufficient.
So, the answer is:
Your machine must be publicly accessible (via proxy if behind a firewall) by a publicly identified name.
That name must also resolve directly to your machine (not by a firewall) if you want efficiency in the "local running case".
Setting this up is machine dependent. But assuming you're behind a NAT firewall which supports virtual server proxies...
Register the unique name in the appropriate DNS server, have it resolve to the publicly-facing IP.
Set up a virtual server on your firewall proxying back to your internal address.
Set up a web-server on your local machine.
Ensure that your local machine itself is configured (in /etc/hosts or Windows equivalent) to map that public address to your 192.168 address.
That basically does it. Impossible to imagine how anything else would. No, it's not possible for a single URI to be defined as "Try file:// in this case, or default to http://". The very definition of URI is a single scheme, as described here:
http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax

You're both correct and incorrect. While two computers can have the same name or the same ip address within a network segment, they only exist within that network.
If you want to uniquely identify a file and a machine, then file://blackbeauty.mydomain.org/c:\myfile.txt is perfectly acceptable, in the sense that the blackbeauty name is "owned" by mydomain.org.
So you will need a way to address machines in FQDN if you want the URL to be resolvable.

Related

How to name IP addresses on micro webserver

I have an stm32H743 micro controller webserver (Cubeide LWIP) which displays a small webpage on my local LAN.
When I look at the router page, I see that all local IP's have a name associated with them.
Ethernet: COM-MID1 80:c7:55:94:12:14 192.168.1.115
STM32 00:80:e1:01:00:23 192.168.1.75
My question is - how do I change the name 'STM32' in my webserver code?
As you may imagine, there are thousands of references in my source code and I cant find the corresponding one. Where is it likely to be?
Thanks
Chris
Could it be that your router is presenting client host names from DHCP option 12?
With lwIP, you can specify the DHCP client host name by #defining the LWIP_NETIF_HOSTNAME option and then setting the hostname-field in the netif struct.

How do you Configure Stapi CMS to Use Custom Domain Name

The default port for strapi is 1337, and default hostname is "Localhost".
I changed the hostname in the server.json file (that's inside the development folder) to "example.com" and saved that change.
However, when I start the program (by typing npm start in the terminal) although the output indicates that strapi is indeed hosting on "example.org" (and says the administration is at "example.org/admin"), upon navigating to example.org:1337, in a web browser, the page is not accessible. Yet, it is accessible when I navigate to localhost:1337.
I'm new to strapi. Any help will be appreciated. Thanks in advance!
Changing the domain name, inside of a server.json configuration file, won't likely result in your web browser being able to resolve that domain.
When your web browser tries to discover the IP address of a domain name, it first looks in your operating system's host file. If it cannot find the ip address of the domain there, it then tries to look for it at the DNS server that provides name-lookup for your local network.
DNS will typically point your domain to the public IP address of your web server and sometimes, if your web server is located on the same LAN you are, it can be tricky to teach the firewall or local DNS server how to route your browser's request within your LAN.
If you do edit your host file, to make the domain point to an internal IP address, you'll want to remove that entry later in order to access the domain when you are not on your LAN.

How to make Windows DNS and WINS settings persist in an Azure VM?

I have a domain controller set up in an Azure VM, and a couple of other servers also set up as VMs. When I set up the server VMs, I configured DNS and WINS to point to the IP address of the DC and joined them to the domain. However, these settings don't survive a shutdown (where the VM is deallocated). When the VM is started back up, DNS and WINS are empty, and domain authentication does not work.
I read that I should provision new VMs via PowerShell commandlets, specifically setting up domain joining. I tried that, and maybe I got something wrong, but it didn't work -- the newly provisioned VM was not joined to the domain, and did not have DNS/WINS set to point to the domain controller.
In any event, my question is: is there any way to re-configure an existing VM to retain network settings through a shutdown or is my only option to figure out how to provision a brand new VM to be married to the domain controller, and then to start from scratch?
Thanks!
You shall never use static configuration on your Azure VM! Neither for IP Addresses, nor for DNS Settings. What I recommend to use is a long story you can read here. It is tested, validated and proven to be effective. A short extract follows:
You should setup at least two sub-nets. Leave one solely for the DNS (and AD/DC if it happens to be the same server). Put all rest of the machines in the other Sub-Net. Thus, you will have 100% predictable IP Address of the DNS Server machine. Having that in mind, configure the DNS for the virtual network via the portal or via PowerShell. But explicitly configure DNS Server for that virtual network. Set IP address for the DNS - the one that you know it will have!
Please do never forget - never manually change network configuration settings for an Azure VM! Doing so is a path to failure.
The above method will help you resolve DNS issue. Now, for the WINS. I don't think you can configure WINS via Virtual Network settings. So, if your VM really loses WINS config, you can create a small powershell script that runs locally on each VM to configure WINS settings upon boot. You can either make this script more generic by looking up the DHCP assigned DNS server and use the same IP Address for WINS, or just put it static, because you know what the IP Address of DNS server will be.
Anton presents a clever and perfectly workable solution, but I wanted to understand what exactly I was doing wrong, because Microsoft guidance suggests that it should be perfectly possible to set up and maintain an Active Directory domain the in the Azure cloud without putting the DC into its own subnet.
After a lot of trial and error (mostly error), I finally figure it out. This is not well documented, so hopefully this will help someone:
In Windows Azure, cloud service is another term for application, or a set of components that scale together. A cloud service is assigned a single DNS name and a single external IP address. In the context of virtual machines, you typically have a 1:1 correspondence between a cloud service and a virtual machine. You only add additional virtual machines to an existing cloud service when you want Azure to automatically load balance and distribute requests among the VMs inside that cloud service, treating them as if they were one.
This brings me to my mistake. Not fully understanding the above, I was attempting to add a new worker virtual machine to the cloud service in which I set up my Domain Controller. That is not a supported configuration. Once I understood that, and properly configured a new VM into its own cloud service, associated with the domain controller as DNS server, everything worked perfectly.

Can I run/access localhost server thru ip and subnet?

Is it possible for me to run a webserver on my computer (shared ip) and access it remotely using my ip + subnet or at least some way that doesn't involve having the IT guys make changes to the machine(s) currently running our virtual servers and/or routing our subnet?
Rationale:
I'm on a computer at work, and I'm making changes to a plugin for Google Website Optimizer. I want GWO to be able to access localhost (i.e. my development environment) so that I don't have to deploy every change to the production server while I'm feeling out the system. (lots of changes; tedious deployment takes up most of the time)
I can't just supply my IP to GWO because that points to our production server (all of our computers at work are on the same IP). If I could construct a URI that points just to my computer, then I suppose I could let GWO view a page on my development environment and interact therewith.
Not only would achieving this purpose be helpful in present circumstances, but it would aid me immensely in that I could let my boss look at what I've got in dev, from his own machine, at his leisure, without deploying changes to production.
I'm not familiar with the Google Website Optimizer, or how/where a plugin for it that you might write would be executed. So I'm going to summarize what I understand about your problem (including some guesses) and go from there, please correct me if I'm wrong.
Your company has one public IP address.
Your workstation and all the hosts on your network are source NAT'ed to the internet.
Port 80 (http) on your public IP address is destination NAT'ed to your production webserver which is hosted as a virtual machine.
You have a development webserver that is hosted on your workstation.
You have reservations about involving your "IT guys" to making routing or system admin changes.
You want your development environment to be accessible from the internet.
First up (assuming everything above is correct):
access it remotely using my ip + subnet - No. Not possible.
Second up:
I could let my boss look at what I've got in dev - Easy, get him to point his browser at your workstation's IP address on your internal network.
Possible solutions for remotely accessible:
Talk to your "IT guys" about getting your dev environment made externally accessible.
Use name-based virtual hosts on your production webserver. Requires setting up a DNS record for the dev site (e.g. dev.your-company) and pointing it to your company's IP address. If SSL is in use this is harder to achieve. You could then:
Proxy requests for a different site name to your workstation (readily achievable with apache).. or
Host your development environment on your production server
Proxy a particular URL path to your workstation. (e.g. /dev/)
Get an unused port (e.g. 8080) on your public IP destination NAT'ed to port 80 on your workstation. Your dev environment URL might then be http://www.your-company:8080/

Get Azure public IP address from deployed app

I'm implementing the PASV mode in a FTP server, and I send to the client the IP address and port of the data end point. This is stupid because the IP is actually where the client is already connecting, so there ire two options:
How could I get the public IP
address from a given instance? Not
the VIP, but the public one.
How could I get the original target
IP address that the user used from
a Socket object? Considering routers and load balancers in the middle :P
An answer to any of this questions would do, although there is another way that could work... may I get the public IP address doing a DNS look up of myapp.cloudapp.net?
A fourth option would be use the Azure Management API library... but, too much trouble :P.
Cheers.
Not sure if you ever figured this out, but here's my take on it. The individual role instances are all behind the Windows Azure load balancer and have no idea what the original, outward-facing IP address is. Also, there's no Management API call that returns IP address - Get Deployment returns the URL but not the IP address. I think the only option is going to be a dns lookup.
Having said that: I don't think you can host a passive ftp server in your role instance (at least not elegantly). You may open up to 25 input endpoints on your role (up from 5 - see my recent blog post about this update), but there's manual work involved in the configuration. I don't know if your ftp application lets you limit your port range to such a small number of ports. Also:
You'd have to define each port as its own input endpoint (this is the manual labor part I mentioned) - input endpoints don't allow a port range to be specified, unlike the internal endpoints.
You'd have to specify the port number that's used internally, and the port numbers would need to be sequential
One last thing on ftp: you should be able to host an sftp server with no trouble, since all traffic comes through one port.
The hack that I'm contemplating right now is to retrieve http://www.icanhazip.com/. It isn't elegant and is subject to the availability of that service, but it gets the job done. A better solution would be appreciated!