nginx-location

Serve protected media files with django

≡放荡痞女 提交于 2021-02-17 20:55:39
问题 I'd like Django to serve some media files (e.g. user-uploaded files) only for logged-in users. Since my site is quite low-traffic, I think I will keep things simple and do not use django-sendfile to tell Nginx when to serve a file. Instead I'll let Django/Gunicorn do the job. To me this seems a lot simpler and for a low traffic site this maybe more secure. But what is the best way to organize the file storage location? Media files are all stored below MEDIA_ROOT and this directory is served

Guide on how to use regex in Nginx location block section?

风流意气都作罢 提交于 2021-02-17 08:28:56
问题 Nginx regex location syntaxe Regex expressions can be used with Nginx location block section, this is implemented with the PCRE engine. What does exactly this feature support as it is not fully documented? 回答1: Nginx location: Nginx location block section have a search order, a modifier, an implicit match type and an implicit switch to whether stop the search on match or not. the following array describe it for regex. # -------------------------------------------------------------------------

NGINX Run multiple application on same port with different route path

萝らか妹 提交于 2021-02-16 14:58:05
问题 I have two applications, app1 is developed in reactJS and app2 in angularJS sharing same login session, - Application 1 http://application-1:1234/ - APplication 2 http://application-2:2345/ My needs is to have a seemless navigation between both apps, as they share the same login credentials. I have created NGINX reverse proxy configuration, server { listen 8080; server_name http://global-ip:8080; location / { proxy_pass http://application-1:1234; proxy_http_version 1.1; proxy_set_header

Expose multiple api uri on the same nginx server block

情到浓时终转凉″ 提交于 2021-02-13 17:33:42
问题 Goal My goal is to setup multiple backend api container exposed on the same nginx server : http://localhost:80/api/account -> call http://account-service:9000/ http://localhost:80/api/cart -> call http://cart-service:9000/ http://localhost:80/api/order -> call http://order-service:9000/ http://localhost:80/api/product -> call http://product-service:9000/ ... My backend container are based on php:7.2-fpm (symfony hosted on every apache container) and they don't have any route called api/${NAME

Docker- nginx -Reverse proxy : host not found in upstream when building with docker-compose

徘徊边缘 提交于 2021-02-09 06:58:19
问题 I am using NGINX container to redirect certain requests to another container.While running docker-compose up -d , i am getting bellow error. " 2019/09/26 18:05:00 [emerg] 1#1: host not found in upstream "abcplus-visualize:61613" in /etc/nginx/nginx.conf:10 nginx: [emerg] host not found in upstream "abcplus-visualize:61613" in /etc/nginx/nginx.conf:10 " below is my docker-compose.yml file version: '2' services: reverseproxy: image: reverseproxy ports: - 49665:2181 restart: always abcplus

NGINX htpasswd 404 not found

。_饼干妹妹 提交于 2021-01-29 08:32:09
问题 I am using NGINX to run my website, I wanted to enable authentication to the website, so I did, using .htpasswd file and it worked, here's part of my default.conf file: server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; auth_basic "Administrator Login"; auth_basic_user_file /usr/share/nginx/html/.htpasswd; location / { root /usr/share/nginx/html; index index.html index.html; } And it works, this way my WHOLE page requires

nginx and nodejs serve images from dynamic folder

冷暖自知 提交于 2021-01-29 03:14:22
问题 Hi i have this nginx setup: server { listen 80; server_name xxxxxx.xx www.xxxxxxx.xx; root /home/xxxx/public_html; location / { proxy_pass http://127.0.0.1:3000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; #proxy_redirect off; #proxy_cache_bypass $http_upgrade; } } My app creates folders inside

Allowing only local network access in NGINX

为君一笑 提交于 2021-01-28 06:25:26
问题 I have a single physical server running several server blocks in nginx corresponding to different subdomains. One of them I'd like to be only accessible from devices on the same local network as the server. I know theoretically this can be done with allow 192.168.1.0/24; deny all; within a location block. When I actually try to access the server from a local device, though, the request is denied. Looking at the access logs, this is because the request is shown as coming from my network's

How does if condition work inside location block in nginx conf?

丶灬走出姿态 提交于 2021-01-27 06:32:04
问题 I have read https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/ I want to check if my rails application has already added a header ( Access-Control-Allow-Origin ) and if it hasn't then add the header. The examples here have tried to explain the behaviour of if condition in nginx.conf http://agentzh.blogspot.in/2011/03/how-nginx-location-if-works.html But I have not understood it. One of the question I have is what is meant when they say a directive or phase directive? I have

How does if condition work inside location block in nginx conf?

假如想象 提交于 2021-01-27 06:31:04
问题 I have read https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/ I want to check if my rails application has already added a header ( Access-Control-Allow-Origin ) and if it hasn't then add the header. The examples here have tried to explain the behaviour of if condition in nginx.conf http://agentzh.blogspot.in/2011/03/how-nginx-location-if-works.html But I have not understood it. One of the question I have is what is meant when they say a directive or phase directive? I have