For uploading a file to a server I am using nginx upload module. What I understood from the docs is that it saves the uploaded file to a temporary directory and only provides information about the file to backend(python bottle server in my case) via POST and information that should be passed to backend can be specified by upload_set_form_field directive.
How can I send the actual destination path to backend ,Since nginx will store in some temporary path and not to the path where the uploading was meant to?
Found out the solution. Should set upload_pass_form_field directive value in nginx config to regex pattern matching destination path field name.
Related
I'm working on an app, with the front(vueJS) and back(symfony with API-platform) separated on the same domain.
We have an NGINX reverse proxy that redirects url base on these rule :
domain.com/ -> front container on port 7000
domain.com/api -> back container on port 8000
domain.com/preview-mrXXX/ -> front container on port 7XXX
domain.com/api/preview-mrXXX/ -> back container on port 8XXX
The problem is that the symfony assets aren't found because the request are on the root url and not the api or preview url.
e.g:
request goes to https://example.com/bundles/apiplatform/web.png
instead of https://example.com/api/bundles/apiplatform/web.png
I could pass a base_url in some header with nginx but I still need to configure symfony to requests on /api/ rather than /.
You can set the base_url for assets in each container for the Framework configuration file. (from the documentation https://symfony.com/doc/current/reference/configuration/framework.html#base-urls).
Since you need it to be dynamic, you can create an .env.local file in each container with the base_url for that particular container. Then in the Framework configuration file mentioned above, you can set the value to %base_url%(the variable you created in the .env.local file) so that it will dynamically resolve to the correct value based on your env. You can refer to more information on env configuration here. https://symfony.com/doc/current/configuration.html
UPDATE: You can also set the value to a real environment variable (from your shell or OS) by using '%env(resolve:ENV_VAR)%' (therefore avoiding defining it in the .env.local file). Relevant documentation: https://symfony.com/doc/current/configuration.html#configuration-based-on-environment-variables
When we send an HTTP request to a web server as to load a web page e.g. http://wwww.nothing_is_here.com, what exactly the server does as to serve our request? Till now, I thought the server was looking to find a file named index (index.html, index.php) which should have HTML content and send it back to our browser. Now, I know this is not always the case. For example, in ASP .NET where we apply routing, home/index path is added to the URL by default as for our app to be routed. That's I cannot understand is how exactly the server acts upon a similar situation. Why it does not return an error message in case there is no index file, how it knows it has to apply routing rules? How can we instruct the server what to do in either case?
What the server does when it receives a request for the root (which is what it will receive in your example), is up to the server configuration. It is not within the control of the client making the request.
The server will be configured to have a default document (file name) in such cases, which is often index.html, but equally could be any file set by the administrator of the server.
The server will often be configured to recognise different hosts (e.g. if it's serving multiple sites on the same interface:port. These different sites will often have different configuration about what the default file name(s) is/are (if any). In some cases the server is configured to display a directory listing of a server-configured site root folder.
I use nginx as my reverse proxy server to fetch image from the file server, which is also a web server.
It works well. but I want add permission check based on the url before send request to my file server. If has permission, just forwarding to my file server, or else just return 404.
BTW, I can't add the check in my file server for some reason.
I think I got the answer.
The module "http_auth_request_module" is what I want. https://www.nginx.com/resources/admin-guide/restricting-access-auth-request/
I want to create an HTTP nginx server which will take whatever POST request comes in
/some/path
will append the post body to some_internal_path/some/path.log
Where some and path would be variables. So /another/place would append to some_internal_path/another/place.log
How can I do this with nginx?
How would a HTTP Server differentiate whether the request in PUT is for a folder creation or a file creation in a directory.
For HTTP GET what I understood is, if the URL has a trailing /, then HTTP Server looks out for a folder with that name and, if does not exist can look out for a file.
How does this work for PUT for a new file and folder creation?
HTTP (the protocol) doesn't have any concept of files or folders. URIs are opaque, except when a relative URI reference is resolved against a base URI.
If you want your server to provide file/folder services, you may want to look into WebDAV (RFC 4918).