Is it possible and how to use NGINX for upload files? - nginx

I use NGINX for serving of static files which (it offloads the backend which serves only "dynamic" requests). But now I need to upload files to server. Is it possible to use NGINX for uploading too? Also it will be good if there is a way to set permissions of uploading files... How to use NGINX for uploading? Which protocol? Module? Some example configuration?
I found only WebDAV but its module looks outdated, also I never used WebDAV before so I am not sure how good is it (I mean performance). What is a typical solution? Do I need to write something, some plugin/module?

There is no built-in module to do the job. There is a third-party upload module.

Related

is it possible to cache a local file to Nginx

I don't know it is relate with Nginx or not.
What I want to do is, my frontend web server is only running Nginx and there is a (Nginx-lua-modules)Lua script which is retrieving some data from backend server and save to a file on frontend web server.
Now I need to cache that file on memory for 60min or 24hr or etc.. but there is only Nginx is running.
So, is it possible to cache from Nginx through Lua script.
Yes you can totally do it, but how you'd go about it totally depends on the size of the file. For something very small, a shared dictionary might be the easiest solution, but for something bigger you should maybe use something like memcached or redis instead.

Symfony not found static files (images, js, txt)

How can Symfony deliver static files without bootstrapping/executing the framework?
For example: if some requests are failing by the webserver(images, js files are not found or something like this) then the framework tries to solve the route. Of course this does not exists.
Is there a way to avoid this or blacklist these extensions?
It could be a cache problem.
If it is :
If it is a cache problem, you could try to clear the cache on the symfony console with cache:clear. If it doesn't work you could try to remove the ressources in the general folder, leaving the original ones in your bundle, and running assetic:dump and assets:install.
If it isn't
Regarding the "remove-symfony-routing" thing, I don't know if it's possible, but it should not done anyways.
What you're asking is to be able to access, from the client side, any file on the server, which constitutes a major security breach.
This could allow the client to get any file on the server, meaning he could get his hands on your javascript or php files which most of the time contain valuable information (such as how your app works or even deadlier : global passwords and config values)
What you could do to access resources from the client would be a route that points to a controller function that could output to browser the file you're looking for, provided that it has an extension you'd be ok to share. For example you could allow any image file but forbid code files such as php or javascript.
EDIT: Or yeah, configure your webserver correctly. 2 simple answers while I was typing :D

What is the most optimized way to define server blocks in nginx config?

I have fifteen virtual hosts (servers) with separate log location for it. I am a bit confused about which would be the best option to write nginx config file for each. All server blocks in one file or a separate file for each server?
Which would be a more efficient way?
Nginx reads config once on start (or reload), so do whatever is more appropriate for you.
I would write related server blocks together in one file, and have one bunch of related servers per file.
Or have one file per server.
Or write them all in one file.
Efficiency is not effected by how you define the blocks in nginx. Thus, it would be same in the given case.
If there's some commonality between your virtual hosts configs, such as general SSL settings or denying certain types of requests, you may want to use includes.
I like to keep separate vhosts config files, it's easier to take one domain offline for maintenance for instance.

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.

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