Nginx Reversed Proxy Requesting Files Above Proxied Folder - nginx

I am using NGINX Proxy Manager with a Custom Location "/setup" which redirects to a reolink IP camera on ip address 192.168.1.50.
The problem is when I open a browser and connect to the target hostname i.e.
http://somedomain.com/setup
What happens, is the reolink camera host attempts to serve javascript, css etc files from itself, at the level above /setup, i.e. the root of the host and these files of course don't exist there.
For example (there are lots of files, this is just one) the host is trying to get it's css files from here:
https://somedomain.com/css/glDatePicker.default.css?timeVersion=1603795049091
When in fact it should be getting them from here: https://somedomain.com/setup/css/glDatePicker.default.css?timeVersion=1603795049091
Any suggestion on how this can be resolved ?

One way you could resolve this is by bundling everything into one HTML file. You can use a tool like webpack to do this, but webpack certainly isn't the only one. Here is another SO question about how to do this with webpack. Honestly just googling "bundle html, css, and js into one file" will bring up some good results too.

Related

Is there a way to download a PHP/ASP/whatever source code without processing it, as plain text?

Suppose the URL http://example.com/test.php. If I type this URL on the browser address bar, the PHP code is executed, and its output is returned to me. Fine. But, what if instead of executing it, I wanted to view it's source as plain text. Is there a a way to issue such request?
I believe that there must be some way, and my concern is that some outsider could retrieve sensitive code, such as configurations file, by guessing it's location. For example, Joomla instalations have a configuration.php on it's root folder. If someone retrieves such file as plain text, then these database credentials have been seriously compromised. Obviously, this could be prevented with proper permissions, but it's just too common to just issue 0777 as everything permissions and forgetting about access denials.
For PHP: if properly configured, there is no way to download it. File permissions won't help either way, as the webserver needs to be able to read the files, and that's the one serving contents. However. a webserver can for instance be configured to serve them with x-httpd-php-source, or the PHP/webserver configuration may be broken. Which is why files which don't need direct access (db config, class definitions, etc.) should be outside the document root, so there is no way those files will get served by accident even when the webserver config is incorrect / failing. If your current hoster does not allow you to store files outside the document root, switch hosting a.s.a.p.
There is a way to issue such request that downloads the source code of http://example.com/test.php if the server is configured to provide a URL to do so. Usually it isn't, so usually there is no way to issue such a request.

Get Static referenced files with http request in meteor

This can be a silly question but I have had some issues with it. I am trying to implement jwplayer with meteor. Jwplayer will try to get a file based off the url you suggest. So I tried to place a file in localhost:3000/test.mp3. When I tried to hit that url I get just the default site. This would work if I used tomcat. Is there something I can do to get the files relative to meteor directory?
Thanks for your help.
In the /public directory, per the docs:
Lastly, the Meteor server will serve any files under the public directory, just like in a Rails or Django project. This is the place for images, favicon.ico, robots.txt, and anything else.
Meteor hasn't yet implemented server side routing and all directories are ultimately flattened. So for the time being, you can access your file at http://localhost:3000/test.mp3, but that may change in the future.

How to handle stylesheet links when local and server directory structures don't match

The document root of my website is directly the server webroot (public_html), and not in a separate subdirectory. This creates a problem for me, because my local website is in a project folder (which is required by my editor, NetBeans), which means that href links to stylesheets need to be of the form:
/projectfolder/stylesheets/stylesheet.css
But on the server, since the website is directly in the webroot, the href url would have to be:
/stylesheets/stylesheet.css
When I asked my host about this, they said I would have to refactor my project to change all the stylesheet links. But I don't know; it seems kind of funny to have to refactor (then "unrefactor") the local website every time I want to upload it to the server. Any other solutions out there?
You don't have to use absolute paths to your stylesheets. Use relative paths instead. Then it won't matter where your files are hosted, so long as they stay in the same positions relative to each other.

Hotlinking my Cascading Style Sheets

Someone told me that another person was hotlinking my CSS file. I was able to find with them using my CSS file. I'm not fine with them hotlinking my CSS file.
Is there anyway to only allow one single URL to use my css file?
I asked the person to stop and told them "you can take it and host it elsewhere", but it seems that they won't listen. I decided to change their background to something borderline nsfw, but that still didn't stop them from doing it again. I could start putting goatse and such, but that is going to be wasting my time.
You can use your .htaccess file to restrict the domain.
Reference 1
Reference 2 http://www.globinch.com/2011/04/13/prevent-hotlinking-of-image-script-css-etc-using-htaccess/
You could wrap the css in php code and check the referrer.
You can block access folders or files using server settings - http://support.microsoft.com/kb/324066 - but if you are in a hosted environment you may not be able to change these settings - you may have to make a request to your host.
If your site is (or supports) PHP, you could put your CSS into a PHP file and include that in the files that need it. Then it would be safe from hot inclusion.

Put file at specific port on Localhost

I need to put a file at this address: http://localhost:51547/file.txt
What folder would I put it in on C:/?
Tony
If I understand your question correctly and you're trying to expose a file via the ASP.NET development server at that location (http://localhost:51547/file.txt) I'm afraid the answer is not quite to your liking.
Basically I don't think you can serve files from the root of the ASP.NET development server (i.e right after the localhost:port/ part - the port is automatically selected by ASP but you can also manually configure it). ASP.NET automatically creates a virtual application path right after localhost:por> and so you're most likely going to be limited to serving files from the virtual application folder. So, assuming you web application name is: "testApp", if you put a file called file.txt in the directory where you're storing the source code for "testApp" it will also become available when you're testing at: http://localhost:port/testApp/file.txt (note the testApp in between the host-name & port, and the file-name)
UPDATE
In light of you comment, here's something you could do. You could try to get a simple HTTP server installed on your development computer and have it serve files on a different port (say port 8000). In that case you would serve file.txt using this secondary HTTP server and it would be accessible at: http://localhost:8000/file.txt.
You could try to install Apache or use IIS which comes with Windows. For Apache, the quickest way to get it going would be to install a WAMP environment. You may also try Lighttpd, and also note that MySQL or PHP are not required at all if you're only serving static files.
Any folder you want. The port designator is specified in IIS itself.
http://support.microsoft.com/kb/149605
I suggest you that if you want to do a site(HTTP) is better to use the port 80 or to do a redirection for another port, remember too that localhoost is a loop back and also take a look at PortForward to check some ports that are used by specific applications and types of servers, and please improve your question.
Regards.

Resources