Prompt
stringlengths
14
160
Instruction
stringlengths
18
2k
Response
stringlengths
8
2k
nginx trouble loading index file
I have this nginx vhost fileserver { # php/fastcgi listen 80; server_name trinityplex.com www.trinity.com; access_log /home/web/trinity_web/log/access.log; root /home/web/trinity_web/public; location / { index index.html index.htm index.php; } }(for domain trinityplex.com), bu...
You haven't configured PHP in the server section so PHP files will obviously be sent as plain text. How are you planning to run PHP? As FastCGI?Update:The configuration you have shown here does still not include anything at all about PHP or FastCGI. Try something like this:# pass the PHP scripts to FastCGI server liste...
Can this package be recompiled
Hello I asked this question to superuser but I did not get a good question there and i really need the answer. I know some of you here can answer this question.I have installed nginx via yum. Now I want to add a module, but I have to compile the source again and include the the new module.But i can't find the source. D...
Redhat and related distributions (fedora, centos) keep their source rpms in a highly regular directory tree. for RHEL5 you want:ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/for other releases, you can browse the ftp server until you find what you want. Otherwise, google for the exact version of ...
oauth2 proxy with Ingress nginx not passing X-Auth-Request headers during standard auth flow
I'm facing an issue withoauth2 proxyand Ingress Nginx (with the latest versions) in a Kubernetes cluster where theX-Auth-Requestheaders are not being passed through to the client during the standard oauth authentication flow. I'm specifically using Azure as the auth provider.Here's the relevant portion of my oauth Prox...
This way will worknginx.ingress.kubernetes.io/configuration-snippet: | auth_request_set $email $upstream_http_x_auth_request_email; add_header X-Auth-Request-Email $email;The only downside is that it will add the header to all the http requests, even for css/js files
How to host a Flask app on a subfolder / URL prefix with Nginx?
I have a flask app which I want to host it on a subfolder of a website, likeexample.com/cn.I configured my nginx likelocation /cn { proxy_pass http://localhost:8000/; }So if I accessexample.com/cn, It will redirect to the index page of flask.However, I have wrote the routes of other pages on flask likeapp.route('/a...
You need to addAPPLICATION_ROOTparams to your flask app:from flask import Flask, url_for from werkzeug.serving import run_simple from werkzeug.wsgi import DispatcherMiddleware app = Flask(__name__) app.config['APPLICATION_ROOT'] = '/cn'if you need to host more than one application on your server, you can configure ngi...
How do I configure proxy_pass on NGINX for PostgreSQL?
I have a PostgreSQL server started at a remote machine on the port15432. I want to configure NGINX to make the database available remotely by hostdb.domain.myand port5432. The configuration I tried is:server { listen 5432; server_name db.domain.my; location / { proxy_pass http://127.0.0.1:15432/; ...
Maybe removehttp://because it is a TCP connection (not a HTTP connection) and addso_keepalive=ontolisten 5432;so the connection stays open.Maybe you have to usestreaminstead ofhttpblock:https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/
Why do we need to map the project files in both PHP-FPM and web server container?
I am pretty new with all of this docker stuff and I have thisdocker-compose.ymlfile:fpm: build: context: "./php-fpm" dockerfile: "my-fpm-dockerfile" restart: "always" ports: - "9002:9000" volumes: - ./src:/var/www/src depends_on: - "db" n...
In your NGinx container you only need the statics and in your PHP-FPM container you only need the PHP files. If you are capable of splitting the files, you don't need any file in both sites.Why isn't it enough to add it just only to my webserver? A web server is a place that holds the files and handles the request...NG...
How to fix, "Error: Request failed with status code 404" in axios Next js
I am using next js when trying to call an API endpoint(dispatching a redux action)in getInitialProps. I am getting the 404 error, my /api/ is proxied in nginx server, all other routes work very well only this route is causing the problem.I have tried by changing the api fetch function call to async but still th...
So the problem is that getInitialProps get executed in the server and axios can not run the server usehttps://www.npmjs.com/package/isomorphic-fetchinstead.
nginx rewrite all trailing / to /index.html with proxy pass
Using nginx as a reverse proxy, I'd like to mimic theindexdirective withproxy_pass. Therefore I'd like nginx to query/index.htmlinstead of/,/sub/index.htmlinstead of/sub/.What would be the best approach to do this ?Not sure if it's relevant, but the proxied server does answerHTTP 200on/, but I'd still like to rewrite i...
Just add :rewrite (.*)/$ $1/index.html last; rewrite (.*)/..$ $1/../index.html last;Should works
Can I create a "private" location in Nginx?
Can I create a location which can be accessed by any other location in nginx config and cannot be accessed directly from outside?I can use a deny directive, but it will also deny access to the locations defined in nginx config.Here's my config -server { listen *:80; server_name 127.0.0.1; location = /auth { ...
You can use something called anamed location. It can't be accessed from the outside at all, but inside your config you can refer to it in some cases:location @nginxonly { proxy_pass http://example.com/$uri$is_args$args; }After creating your named location you can refer to it insomeother places like the last item in...
localhost sent an invalid response. ERR_INVALID_HTTP_RESPONSE
I am working on enabling http2 in nginx docker. I am getting this error when I calling to localhost. My nginx configuration file as below.server { listen 2020 http2; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; ind...
I have found the solution for this. It is needed to enable SSL in nginx in order to achieve http2. I tried it and it's working well. I found the answer from this link.How To Set Up Nginx with HTTP/2 Support on Ubuntu 16.04Now my config file as below.server { listen 443 ssl http2; server_name localhost; ssl_cert...
Automatically refresh page on 502 Bad Gateway error
When I’m doing maintenance on my site and restart the server, sometimes NGINX returns a 502 Bad Gateway error. The same thing sometimes happens under heavy load. This is confusing to my visitors who don’t realize the issue is probably temporary. Is there any way I can have visitors automatically refresh the page when t...
You can achieve this by using Javascript to check the HTTP status code for the current page, and refresh the page when the server is back up (i.e. returns the200 OKstatus code). To avoid hammering the server when many users encounter the502error page at once, I’d recommend using thetruncated binary exponential backoffa...
Nginx return under location
I am currently facing a small problem using nginx to redirect to another host. I want to for example redirecthttps://service.company.com/new/test.htmltohttps://new-service.company.com/test.html.For now I have following configuration, which redirects me tohttps://new-service.company.com/new/test.html.server { # ...
You want to rewrite the URI and redirect. You can achieve it usinglocationandreturndirectives, but arewritedirective would be the simplest approach:rewrite ^/new(.*)$ https://new-service.company.com$1 permanent;Seethis documentfor more.BTW, the problem with yourlocationblock solution, was the regular expression capture...
uWSGI NOT working with .ini file
uWSGI NOT working with .ini file but works directly from command line.For this project, I'm usingPythonwithDjango,NGinXanduWSGI. When running the server configuration with parameters directly in the command line, it works but does not work when using the .ini file.In myNGinXconfiguration, I have this uwsgi_pass command...
In my project, uwsgi run in docker containersocket = :8000not workbut, change tohttp-socket = :8000it workhope that will be helpful
Docker for Mac nginx example doesn't run
Mac 10.11.5 here. I am specifically trying to installDocker for Mac(notDocker Toolbox or any other offering). I followed all the instructions on theirInstallation page, and everything was going fine until they ask you to try running an nginx server (Step 3. Explore the application and run examples).Runningdocker run he...
correctedThe image exposes 80 as the httpd porthttps://github.com/nginxinc/docker-nginx/blob/11fc019b2be3ad51ba5d097b1857a099c4056213/mainline/jessie/Dockerfile#L25So using-p 80:80should work and does work for me:docker run -p 80:80 nginx 172.17.0.1 - - [22/Aug/2016:17:26:32 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla...
Letsencrypt - Change installed certificates to use --webroot for renewal instead of --standalone
I have already set up certificates using the --standalone flag which is working great but the problem is I have to stop Nginx server every time I have to renew the certificates because the --standalone option requires port 80 to be free.The --webroot method does not require stopping the server and essentially taking do...
I ended up also asking the same question onLetsencrypt forumswhere I got an answer.Basically, when you have created certificate with--standaloneplugin, just regenerate it with--webrootand then it can be updated with--webrootfrom next time onwards.sudo ./letsencrypt-auto certonly -a webroot --renew-by-default -w -d
Force nginx to verify upstream certs
I am trying to institute TLS at every layer of a proxying path. What I'm seeing is Nginx allowing an upstream to have a self-signed certificate. Is there any way to lock the authorities that are accepted when passing traffic to an upstream?end-user --1--> nginx01 --2--> nginx02 --N--> nginxNnginx01 has a trusted ...
Useproxy_ssl_verify on; proxy_ssl_trusted_certificate /path/to/your_selfsigned_ca_cert.pemFor additional details you can refer to nginx proxy docshere
Vue router server configuration for history mode on nginx does not work
I read the following note fromvue router documentationNote: when using the history mode, the server needs to be properly configured so that a user directly visiting a deep link on your site doesn't get a 404.So, I try to configure my nginx like the followingserver { listen 80 default_server; listen [::]:80 de...
I just readmattstauffer blog postand finally found way to do in Laravel route. Like the followingRoute::get('user/{vue_capture?}', function() { return View::make('user.index'); })->where('vue_capture', '[\/\w\.-]*');It does not return 404 when user directly visiting a deep link to site.
How to change request_uri in nginx proxy_pass?
I am running a django application through gunicorn via unix socket and I have my nginx configuration which looks like this :Current NGINX config File :upstream django_app_server { server unix:/django/run/gunicorn.sock fail_timeout=0; } server{ listen 80; server_name demo.mysite.com; location / { ...
One approach is to userewrite ... break, for example:location / { try_files $uri @proxy; } location @proxy { rewrite ^ /demo$uri break; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://django_app_server; }Seethi...
Nginx configuration to cache angular app files
I have the following configuration to run an angular.js app, which works fine.location / { root /usr/share/nginx/html; index index.html; expires -1; add_header Pragma "no-cache"; add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"; try_files $uri $uri/ /i...
You need to make sure that the "root" defined in the server section matches what you want. Or define "root" under your regex locationlocation ~* \.(jpg|jpeg|png|gif|swf|svg|ico|mp4|eot|ttf|otf|woff|woff2|css|js)$. Without a root defined there nginx may be reverting to global definition under the server section.
Nginx location regex capture variable
I have this REST API URL:http://localhost:4000/api/v2/stocks/accounts/1162/tradingsI want it to proxy_pass to URL:http://localhost:4001/api/v2/stocks/accounts/1162/tradingsWhere 1162 is the URL parameter which can be other value.I have the following:location ^~ /api/v2/stocks/accounts/([^/]+)/tradings { proxy_pas...
You can do it just like this. NOT '^~'location ~ /api/v2/stocks/accounts/([^/]+)/tradings { proxy_pass http://localhost:4001/api/v2/stocks/accounts/$1/tradings; }As described bynginx.org.The^~is often to matchdirectory, like this below:location ^~ /dir/ { # some actions }
HTTPS + gzip: Is it a security vulnerability if I only gzip non-sensitive files?
As I understand it, gzipping opens up a security vulnerability (BREACH/CRIME) if I use it with SSL/HTTPS.What if I only use it on my CSS and JS files, is it still a security vulnerability if those files are served off my server over HTTPS?
From what I understand, the answer is no - it's not a security vulnerability. CRIME/BEAST attack injects chosen plaintext to uncover original plaintext; in your case this would CSS and JavaScript, which carry no security value. (Presumably, you serve them over HTTPS to avoid mixed content warnings on the browser).The a...
One domain name for multiple Rails apps with Nginx and Unicorn
I have two Rails apps and I want to host them with just one domain name like this:app1.example.com app2.example.comI have a VPS on digital ocean and I have already run one app with Nginx and Unicorn. This is my nginx configuration file:upstream app1{ server unix:/tmp/unicorn.app1.sock fail_timeout=0; } #upstream app2...
ok since you already defined 2 subdomains, you just need to add theserver_nameto the nginx blocksupstream app1{ server unix:/tmp/unicorn.app1.sock fail_timeout=0; } upstream app2{ server unix:/tmp/unicorn.app2.sock fail_timeout=0; } server{ listen 80; server_name app1.domain.com; root /var/www/app1/public; ...
configuring nginx to serve static files from a custom directory
So I want to serve static files from a specific folder on a specific port with Nginx.$ nginx -c `pwd`/nginx.confmy localnginx.confgoes like:http { server { root .; listen 8080; } }but i'm getting this error:nginx: [emerg] no "events" section in configurationI can see the events section in/etc/ng...
You need to specify minimal events block:events { worker_connections 1024; }Root needs to be declared with absolute path on the filesystem.
nginx limiting the total cache size
I am using nginx to cache requests to my uwsgi backend usinguwsgi_cache_path /var/cache/nginx/uwsgi keys_zone=cache:15M max_size=5G;My back-end is setting a very long expires header (1 year+). However, as my system runs, I see the cache topping out at 15M. It gets up to that level, then prunes down to 10M.This causes...
Expires header (and some other headers) is honoured by nginx to determine if a response is cacheable, but it's not used to determine how long to cache it.By default, your inactive cache will be deleted after 10 min. Could you increase that number to see if it makes a difference?proxy_cache_path path [levels=levels] key...
Auto-versioning CSS/JS in nginx
I have a setup where nginx is serving all static content (CSS/JS). Our problem is that when we update the static content the browser doesn't necessarily update them immediately, causing problems when we're pushing new versions.I would like to have a nginx plugin that basically replaces all calls to CSS/JS and ads a ver...
Generally, this is done in the application itself, not at the webserver level. The webserver generally only knows what to serve, and from where. Both PHP and Rails have the ability to do what you're describing above, but again, that's within the application itself.From what I can tell,this articleis a good step-by-st...
How do I debug nginx/php-fpm for site that hangs?
I need some tips on how to debug a new server config that hangs. This site itself is a very big instance of Drupal. Big as in a 45+ MB of PHP memory per page load with APC functioning.The site itself does run on another server with nginx/php-fpm/apc. The new server I'm setting up has a custom PHP 5.3 build.nginx is ...
When you see that error log entry in your php-fpm error log, it's actually providing a helpful stack trace of the slow php process.In your php-fpm configuration file (e.g. /etc/php-fpm.d/www.conf), take a look at therequest_slowlog_timeoutandslowlogsettings. The first defines how many seconds until a request is conside...
Passenger+Nginx show custom 500 page
I'm using Rails 3.2 with passenger+nginx. I want to display nice custom 500 page when the db server is down. I want to show something when my rails app cannot be started. Here is my nginx:server { listen 80; server_name localhost; root /var/www/store/public; error_page 500 /500.html; # root location / {...
Phusion Passenger author here. Usepassenger_intercept_errors off.
Is it a bad idea to use port 443 for Socket.IO?
According to the following post, some networks only allow a connection to port 80 and 443:Socket IO fails to connect within corporate networksEdit: For clarification, the issue is when the end user is using a browser at work behind a corporate firewall. My server firewall setup is under my control.I've read about Nginx...
Non-encrypted traffic on port 443 can work, but if you want compatibility with networks with paranoid and not-quite-competent security policies you should assume that somebody has "secured" themselves against it.Regardless of silly firewalls you should use SSL-encrypted WebSockets, because WebSocket protocol is not com...
Case sensitivity in URL issue on Linux + NGinx + Kohana + php
There is an issue/bug/feature/whatever on Linux + NGinx + Kohana :We have to make sure that we keep all our file names in lowercase only.We can't have anything like "setUserServer.php". It simply doesn't work. No idea why. If we give the name of the same file as "setuserserver.php", it runs.This problem doesn't exist o...
Solution is sticking to the naming scheme of kohana: all files lower caseWindows by default is not case sensitive, and linux is. Can't "solve" that
Is it possible to embed nginx in a C/C++ application
The application runs in Linux, Windows, Macintosh.Also, if yes, how much effort is required?
Does nginx run on windows?I think you'd have a much better result using an existing library that includes a good http server. My first choice would belibevent.
How to monitor nginx passenger with monit
I have several rails applications deployed by nginx passenger. I want those applications to be monitored by using monit. How can I monitor those applications using monit? Should I monitor nginx as well?
This is how I solved this. First, I added to application.rb:# Monit support if defined?(PhusionPassenger) require 'pidfile_manager' PhusionPassenger.on_event(:starting_worker_process) do |forked| if forked # We're in smart spawning mode. PidfileManager.write_pid_file else # We're in conser...
Django and dynamically generated images
I have a view in my Django application that automatically creates an image using the PIL, stores it in the Nginx media server, and returns a html template with a img tag pointing to it's url.This works fine, but I notice an issue. For every 5 times I access this view, in 1 of them the image doesn't render.I did some in...
We had this problem a while back when writing HTML pages out to disk. The solution for us was to write to a temporary file and then atomically rename the file. You might also want to consider usingfsync.The full source is available here:staticgenerator/__init__.py, but here are the useful bits:import os import stat imp...
nginx cached index.html force reload
During a server migration a new nginx configuration was missing cache conrol directives. Hence, we ended up with a cachedindex.htmlwhich is very bad for our SPA that is not refreshed anymore if we deploy new code. We need the index.html to not be cached.This was our (bad) nginx config that was online some days:server {...
There is no way manually reset browser cache on user side (browser) while the client do not request to server for new content. In this case can be useful access to any scripts, that you SPA is download without cache. In this case you can change this script and run force reload page (but be careful - you need any flag f...
relation between rewrite uri and set variable statements in nginx
Im trying to find what is the relation between rewrite statement in nginx location block and set variable statement inside location block. Why im asking is because of different behaviour in below 2 caseswhat does not work- getting http 500 as url is not set- when set is after rewrite statement*location ~ ^/offer/ { ...
Fromthe documentation:breakstops processing the current set of ngx_http_rewrite_module directives as with the break directive;Both therewriteandsetdirectives are implemented by thengx_http_rewrite_module.The statements are evaluated sequentially within thelocationblock. Thebreak(either on its own, or part of arewrite.....
Is there a way to enable/setup ESNI in Nginx?
I was looking around for a way but I've only got that Nginx does implement the normal SNI and that's it.Can it be that ESNI is still a "not yet ready" feature for Nginx?
Since ESNI (or ECH, as it's now called) isnot supported by OpenSSL, it can't be supported by nginx, either.
How to add blocking IP rules on each nginx-ingress host
I have searched a lot and I didn't find the solution. I want to block/allow ip's into each host definition in the nginx-ingress, not per locations.This is the ingress.yaml:apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress-nginx annotations: kubernetes.io/ingress.class: "nginx" spec: rules: ...
You need to split thosehostdefinitions into separateingressrules.Then you can use annotation towhitelist source rangeusing followingannotation:nginx.ingress.kubernetes.io/whitelist-source-rangeSomething like this:apiVersion: extensions/v1beta1 kind: Ingress metadata: name: app1-ingress annotations: kubernetes.i...
Django channels daphne returns 200 status code
I have setup a Django application with Nginx + uwsgi. The application also uses django-channels with redis. When deploying the setup in an individual machine, everything works fine.But when I tried to setup the app in 2 instances and setup a common load balancer to coordinate the requests, the request get properly rout...
Try to add following headers, hope that this will help:server { location / { proxy_pass http://webservers; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }Fullofficial instructionabout how to setup Django Channels + Nginxc...
How do I map a location to an upstream server in Nginx?
I've got several Docker containers acting as web servers on a bridge network. I want to use Nginx as a proxy that exposes a service (web) outside the bridge network and embeds content from other services (i.e. wiki) using server side includes.Long story short, I'm trying to use the configuration below, but my locations...
You must turnproxy_pass http://wiki;toproxy_pass http://wiki/;.As I know, Nginx would take two different way with/without backslash at the end of uri. You may findmore details aboutproxy_passdirectiveon nginx.org.In your case, a backslash(/) is essential as a uri to be passed to server. You've already got error message...
Cascade index.php in nginx "try_files"
In Apache it is possible to redirect everything to the closest index.php, using.htaccessExample folder structure:/Subdir /index.php /.htaccess /Subdir /Subdir/.htaccess /Subdir/index.phpIf I access/somethingit will redirect to the root index.php, and if I access/Subdir/somethingit will redirect toSubdir/index.phpCa...
Theindexdirective should take care of most of thatserver { index index.php; ... }If your setup dictates using try_files, then this should work for you:location / { try_files $uri $uri/ $uri/index.php?$query_string =404; }You can also capture the location and use as a variable:location ~ ^/(?) { # Variab...
Angular app + NGINX + Docker
I have problem with serving Angular app using nginx on docker. Problem is only when I want to turn on SSL on site. I'm using Bamboo for deployment.Here is my Dockerfile:FROM node:8.6 as node WORKDIR /app COPY package.json /app/ COPY ssl/certificate.crt /app/ COPY ssl/ /app/ssl RUN npm install -g @angular/cli --unsafe...
To enable the SSL you need to configure the Nginx for it. As far as I see in your code, you are still using the default Nginx config without any modifications. Here is an example onhow to enable SSL on Nginx. The main components are:server { listen 443; server_name jenkins.domain.com; ssl_certificate ...
Dockerized nginx isn't serving HTML page
Mac OS here, running Docker Version 17.12.0-ce-mac49. I have the following super-simpleDockerfile:FROM nginx COPY index.html /usr/share/nginx/htmlI create my Docker image:docker build -t mydocbox .So far so good, no errors. I then create a container from that image:docker run -it -p 8080:8080 -d --name mydocbox mydocbo...
See if you can followthis example:FROM nginx:alpine COPY default.conf /etc/nginx/conf.d/default.conf COPY index.html /usr/share/nginx/html/index.htmlIt uses adefault.conf filewhich does specify the index.html usedlocation / { root /usr/share/nginx/html; index index.html index.htm; }Change in thedefault.conft...
"ssl_preread" is not working in NGINX
I am trying to implement "ssl_preread" in my nginx. My nginx is compiled with "--with-stream_ssl_preread_module" this module.I mentioned "ssl_preread on;" in server directive of nginx.conf. But i am getting below error.nginx: [emerg] "ssl_preread" directive is not allowed here in /opt/nginx/conf/nginx.conf:43I am follo...
Compile with both modules--with-stream--with-stream_ssl_preread_moduleCreate a stream block outside http blockstream { upstream app { server IP1:Port; server IP2:Port; } map $ssl_preread_server_name $upstream { default app; } server { listen PORT; ssl_preread...
Nginx redirect http to https and remove trailing slashes with one single redirect
I want to redirect http to https and remove trailing slashes in nginx with one single redirect. The solution I have today is the following:server { listen 80; server_name www.example.com rewrite ^/(.*)/$ /$1 permanent; return 301 https://$host$request_uri; }The problem with this solution is that it will...
You already had the components of a correct solution. Use the scheme and hostname, together with the capture to construct the destination URL:rewrite ^/(.*)/$ https://$host/$1 permanent;
Folder Structure for Nodejs Multi Subdomain site
So i am building a website using NodeJS where i will use Nginx as a reverse proxy to my app/apps. I will be using jade and sharing some layouts between subdomain and displaying specific content according to subdomain. I am trying to figure out from alot of research the best method of structuring the app. Is the best wa...
The main issue with using the same domain across multiple apps is security in regards to cookies. If apps are independent, then you might want to ensure a vulnerability in one app would not necessarily affect your other apps.Otherwise, with nginx, there is really no limitation on your setup, however you decide to go. ...
Mixed content: page at https was loaded over https but requested an insecure
I'm using Nginx + flask-socketio + aws elb and when the URL is loaded on https I'm getting the following error message which is something related to the Nginx and socket, please help on this,socket.io.min.js:2 Mixed Content: The page at 'https://localhost/' was loaded over HTTPS, but requested an insecure XMLHttpReques...
Take a look into your.jsfile, make sure that you are using the right ajax URL (//your_site.com/handler, instead ofhttp://your_site.com/handler), for instance:$.ajax({ url:'//your_site.com/handler',dataType:'json',type:'get', success: function(data){...}, complete:function(xhr, textStatus){...} });
MediaWiki File Not Found with File:example.jpg when using short urls
I am trying to set up a wiki using Nginx.When I use/wiki/File:image.jpgNginx returns 404.When I use/index.php?title=File:image.jpgit works correctly.server { listen 80; listen [::]:80 ipv6only=on; root /usr/share/nginx/mediawiki; index index.php index.html index.htm; ... location /wiki/ { ...
I changed the regular expression that tries to serve static resources directly.server { ... location ~* \.(js|css|gif|ico)$ { try_files $uri /wiki/index.php; expires max; log_not_found off; } ... }
NGINX configuration for static and PHP files
I am trying to configure nginx to serve static and PHP files. The config I have isn't working. I want the following local folder structure:src/static/ -> contains HTML, CSS, JS, images etc src/api/ -> contains PHP files for a small REST serviceIf I visithttp://mysite.localI want to be served files from the /static...
The initial problem is therootdirective in thelocation /apiblock, which should not include the location component as this gets appended as part of the URI, so:location /api { root /var/www/mysite/src; ... }will result in a local path of/var/www/mysite/src/api/index.phpwhen presented with the URI/api/index.php. ...
Go - How to decode/convert a txt file contains hex chars into readable string
I've got a log file, where each line is a JSON. Due to some Nginx security reasons, the logs are being saved in a hexadecimal format (e.g. the char " will be converted to \x22). Here is an example of a JSON line:{ "body_bytes_sent": "474", "params": {\x22device_id\x22: \x221234567890\x22} }My goal:Read the file line by...
You can usestrconv.Unquoteto convert the string to a normal one:package main import ( "encoding/json" "fmt" "strconv" ) func main() { // this is what your input string looks like... qs := "{\\x22device_id\\x22: \\x221234567890\\x22}" // now let's convert it to a normal string // note tha...
Why is nginx complaining of an unknown directive?
I'm trying to direct all HTTP requests resembling/to a specific HTTP server running on the localhost. Below is the relevantlocationline in my nginx.conf:# nginx.conf upstream django { server unix:///app/django.sock; # for a file socket } server { access_log /var/log/access.log; error_log /var/log/error.lo...
Actually you have another error. I've checked your server block and got following:$ sudo nginx -t nginx: [emerg] invalid URL prefix in /etc/nginx/sites-enabled/test:23 nginx: configuration file /etc/nginx/nginx.conf test failedThis is error about missing protocol inproxy_pass localhost:8000;line. After fixing it toprox...
Use environment vars of container in command key of docker-compose
I have two services in mydocker-compose.yml: docker-gen and nginx. Docker-gen is linked to nginx. In order for docker-gen to work I must pass the actual name or hash of nginx container so that docker-gen can restart nginx on change.When I link docker-gen to nginx, a set of environment variables appears in the docker-ge...
I've addedentrypointsetting to dockergen service and changedcommanda bit:dockergen: image: jwilder/docker-gen:latest links: - nginx volumes_from: - nginx volumes: - /var/run/docker.sock:/tmp/docker.sock - ./extra:/etc/docker-gen/templates - /etc/nginx/certs tty: true entrypoint: ["/bin/s...
Restarting Containers When Using Docker and Nginx proxy_pass
I have an nginx docker container and a webapp container successfully running and talking to eachother.The nginx container listens on port 80, and uses proxy_pass to direct traffic to the IP of the webapp container.upstream app_humansio { server humansio:8080 max_fails=3 fail_timeout=30s; }"humansio" is set in the/e...
I prefer to run the proxy (nginx of haproxy) directly on the host for this reason.But an option is to "Link via an Ambassador Container"https://docs.docker.com/articles/ambassador_pattern_linking/https://www.digitalocean.com/community/tutorials/how-to-use-the-ambassador-pattern-to-dynamically-configure-services-on-core...
How do you dynamically set nginx root based on location?
I can't find any information on doing this specifically but I am basically trying to catch a location like:http://domain.com/project/Content/Images/image.pngand I want it to point to root like so:/var/www/$project/Content/Images/image.pngThis is what I tried to put together but it doesnt seem to be working:location ~ ^...
I think you are really close. You have an extra ^ in your regex search string. ^ means "match from the beginning of the line"location ~ ^/(?.+)/Content/(?.+)$ { root /var/www/$project/Content/$content; }
Variable interpolation inside Map directive
I am trying to map a variable inside the http directive in Nginx.When left alone, the variable alone gets expanded, if I add anything else to the string the expansion stops working.http { map $host $foo { #default "$host"; # - this works fine and returns 'localhost' default "Thi...
As stated in themapdirectivedocumentation:The resulting value can be a string or another variable (0.9.0).Update:This functionality has been added to version 1.11.2 of NGinx, as per Comment #7 here:https://trac.nginx.org/nginx/ticket/663#comment:7
Difference between Celery and Gunicorn workers?
I'm deploying a Django app with gunicorn, nginx and supervisor.I currently run the background workers using celery:$ python manage.py celery workerThis is my gunicorn configuration:#!/bin/bash NAME="hello_app" # Name of the application DJANGODIR=/webapps/hello_django/hello ...
Celery and gunicorn are different things. Celery is an asynchronous task manager, and gunicorn is a web server. You can run both of them as background tasks (celerydto daemonize celery), just feed them your django project.A common way to run them is usingsupervisor, which will make sure they stay running after you log ...
nginx url rewrite for reverse proxy
I have an nginx on port 80 and a tomcat on port 8080 configured as upstream.The war application in tomcat listen to /pwm.I would like to configure nginx to a reverse proxy for tomcat and rewrite the url "/" to "/pwm".example: user types "web.noc.local" in browser and nginx rewrites the url to web.noc.local/pwm and redi...
Ok, I found a solution for me:location / { rewrite ^ http://web.noc.local/pwm/ last; } location /pwm { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_max_temp_file_size 0; proxy_buffering off; p...
Meteor + accounts-facebook redirecting to wrong url
I'm currently developing on my server, not on my personal computer, but it seems to be impossible to tell it to Meteor, as I'm trying to use Facebook login. The expected login url forapp.example.comishttps://www.facebook.com/dialog/oauth?client_id=&redirect_uri=http://app.example.com/_oauth/facebook?close&But I always ...
You should set the environment value ROOT_URL before executing meteor, i.e.ROOT_URL=http://app.example.com meteor run
Flask, Nginx, uWSGI Python Application not found
I'm trying to setup NGINX, uWSGI and Flask. I'm currently getting,uWSGI ErrorPython application not foundI get some strange errors in my uwsgi error file, which you can find at the bottom of my post.I'll get straight to it, this is on a fresh VPS running Ubuntu 13.04 64bit, these are the commands I ran.sudo apt-get upd...
Fixed by adding PythonPath in my ini file, since I have my python files in an app subdirectory and by using the filename as the module.pp=/home/user/projects/python/flask/project/app module=filename
Nginx detached subrequest
I need to do some time consuming processing on images that are served by NGinx, and I'd like to be able to respond quickly with partially processed images from cache.Here are the steps of I'd like:User make first request for image AUser get image A without any processingConnection is freedimage A is put on cache (A0)A ...
I have tried using post_action and ngx.location.capture, but both of them wait for the subrequest to finish to close the connection.Take a look atngx.eof()documentation.Update:http://wiki.nginx.org/HttpLuaModule#ngx.eof
Multiple redmine instances best practices
I'm studying the best way to have multiple redmine instances in the same server (basically I need a database for each redmine group).Until now I have 2 options:Deploy a redmine instance for each groupDeploy one redmine instance with multiple databaseI really don't know what is the best practice in this situation, I've ...
The two options are not so different after all. The only difference is that in option 2, you only have one copy of the code on your disk.In any case, you still need to run different worker processes for each instance, as Redmine (and generally most Rails apps) doesn't support database switching for each request and som...
Context path for tomcat web application fronted with Nginx as reverse proxy
I'm trying to deploy an web application on tomcat server fronted with Nginx. The problem I encounter is tag in my jsp pages is printing out "incorrect" (it is correct from tomcat point of view) context path.My Web app on tomcat is deployed on context path: /webApp1 with tomcat running on port 8080. So the web applicat...
I managed to fix this problem after spending lots of time.There's a 3rd party module for nginxHttpSubsModule, which allows you to replace strings in the response body (eg. html).So the problem can be fixed by:location / { http://localhost:8080/webApp1; subs_filter_types text/html; subs_filter '/webApp1' '';...
How to config nginx to read nginx.conf in current working directory?
I have intalled nginx on Windows and put annginx.confin my http root directory, but it seems this path is not included, I can include it by includingc:/http_default/nginx.conf, but I want nginx to automaticaly include anynginx.conffor current working directory. Example: forhttp://mydomain.com/test/index.php, I wantc:/h...
Your best option is to first have standardized directory structure (e.g. c:\www\example.com ). Then in each site directory have a directory for your root and for conf files. Then you'd use this in your main nginx.confhttp { }section.include c:/www/*/conf/nginx.conf;Then each site's nginx.conf will get loaded when you s...
Tracking system and real time stats analysis in Python
This question is related to an older question:MySQL tracking system. In short: I have to implement a tracking system that will have high loads using Python. For the database part I've settled on mongoDB (which sounds like the right tool for this job). The development language will be Python.I was thinking of using seve...
Sounds like MongoDB will be a good fit for this - fast updates with advanced operators, and M/R for batch offline processing. I think CherryPy behind Nginx should work well too. If you go the mod_wsgi route just watch out forthis issue.
Minimal nginx configuration to start it from the command line
I wish to just runnginxon the command line, in the foreground, as my own user, with configs and files to serve from the current directory.What is the minimal configuration and CLI invocation that will start nginx?
I found the following to be the minimal starting configuration that serves contents from the givenhtmldirectory in the current$PWDdirectory:Runnginx -p $PWD -e stderr -c nginx.confwithnginx.confbeing:# Run nginx using: # nginx -p $PWD -e stderr -c nginx.conf daemon off; # run in foreground events {} pid nginx.p...
Nginx RTMP with Flask
I have followed along the documentation/tutorial on how to set up the config file for RTMP streaming from here:https://www.nginx.com/blog/video-streaming-for-remote-learning-with-nginx/and it is pretty straight forward. However, I am not sure how I can have my backend built on Flask to redirect the stream to some HLS/D...
Use the HLS protocol (HTTP Live Streaming). Nginx knows how to render HTTP perfectly. So, you just need to create and update the playlist and fragments of the HLS stream, as well as monitor the removal of old fragments. To do this, there is a nginx-rtmp-hls module. It is located in the hls directory, but it is not coll...
ECS Fargate NGINX container not showing errors in CloudWatch logs
My nginx Dockerfile:FROM nginx:1.15.12-alpine RUN rm /etc/nginx/conf.d/default.conf COPY ./nginx/nginx.conf /etc/nginx/conf.d # Forward request logs to Docker log collector RUN ln -sf /dev/stdout /var/log/nginx/access.log \ && ln -sf /dev/stderr /var/log/nginx/error.log EXPOSE 80 ENTRYPOINT ["nginx", "-g", "daemon o...
you should checkECS_Execution_Role_Policy. it should containslogspermission. like :{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ecr:GetAuthorizationToken", "ecr:BatchCheckLayerAvailability", "ecr:GetDo...
Can't serve static assets from docker containers behind Nginx reverse proxy
I'm trying to use Nginx as a reverse proxy to serve two containers. Here is a part of my Nginx conf file:upstream dashboard { server dashboard:80; } upstream editor { server editor:80; } server { listen 80; server_name example.com; location / { proxy_pass http://dashboard; } ...
If I understood correctly you have static resources oneditoranddashboardupstreams and in both cases the URL is the same/static/some.resourceBecause you cannot differentiate based on the URL you could configurenginxto try if the file exists ondashboardfirst and proxy the request toeditorif not found.upstream editor { ...
Dockercompose, Nginx, Resolver not working
I use an nginx container with this config:set $ui http://ui:9000/backend; resolver 127.0.0.11 valid=5m; proxy_pass $ui;This is needed, because the "ui" container wont necessarly be up when nginx starts. This avoids the "host not found in upstream..." error.But now I get a 404 even when the ui-container is up and runnin...
The answer is like in this post:https://stackoverflow.com/a/52319161/3093499Only change is putting the resolver and set variable into the server-body instead of the location.
Create react app service worker nginx no cache configuration
I am trying to set cache header for service worker through nginx increate react app project, in the configuration, I triedlocation /service-worker.js { add_header Cache-Control "no-cache"; proxy_cache_bypass $http_pragma; proxy_cache_revalidate on; expires off; access_log off; }However when I load my page, sw...
as per your configurationservice-worker.jsmust be in/root directory defined withrootnginx directive.Please check if the file is present there. If you are using express and express static and have placed the file in public/assets directory, it won't work. if for this file you want to to have different location. you can ...
AWS Elastic Beanstalk - NodeJS : Get certificate SSL from Letsencrypt without Beanstalk Load Balancer
For my nodejs application in Elastic BeanStalk, without Beanstalk Load Balancer I want to set up a Letsencrypt certificate and keep the classic domain provided by AWS : xxx.xxxx.elasticbeanstalk.comAfter several searches I found two possible solutions :1 - Using an .ebextensions file => to install Certbot, get a Letsen...
I finally found the solution :I took inspiration from thisscriptand created one using WEBROOT MODE.I created a git to share this solution :https://github.com/SammyHam/LetsEncrypt-SSL-config-for-Elastic-Beanstalk
nginx rewrite url and remove last part
Sorry if this question was asked many times. I can't make nginx do proper rewrite. I need to remove last part of the url. For example, this is the url I have:https:/mydomain.com/this/is/some/url/page/0 https:/mydomain.com/this/is/some/url/page/1I need to rewrite these both to this:https:/mydomain.com/this/is/some/urlTh...
The0|1should be within parentheses or redefined as a character class.The rewritten URI needs a leading/as allnginxURIs have a leading/.So all of these should be equivalent:rewrite ^/(.*)/page/(0|1)$ /$1 last; rewrite ^/(.*)/page/[01]$ /$1 last; rewrite ^(/.*)/page/[01]$ $1 last;There's a useful website for regular expr...
nginx reverse proxy from rails to wordpress
I have a Ruby on Rails application and a Wordpress blog hosted on separate EC2 instances.I'm trying to make the Wordpress blog to act like a subfolder of the Rails application (example.com/blog instead of blog.example.com) for better SEOThe Rails application can be accessed through http and https (http is redirecting t...
Now that you have your blog working athttp:///blogyou need fix few more thingslocation ^~ /blog { proxy_pass http://<>/blog; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_redirect http:/// https://$host/; proxy_cookie_domain $host; pr...
Angular 4 - Nginx / Refresh shows bad page
I have an Angular 4 application deploy on a remote server with Nginx, and accessible with this address:http://xx.xx.xx.xx/app. The app works well, I can navigate in my website but when I refresh one page, for examplehttp://xx.xx.xx.xx/app/page1, it displays the index.html page of nginx.Nginx's pages are located in/usr/...
Try to add this in your AppModule:import { HashLocationStrategy, LocationStrategy } from '@angular/common'; @NgModule({ // ... providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}], // ... }) export class AppModule {}
How to set up kubernetes NGINX ingress in AWS and SSL termination
I set up a kubernetes cluster in AWS using KOPS; now I want to set up an NGINX ingress controller and terminate TLS with AWS managed certificate. The topology in my understanding is AWS ELB is facing the internet and terminates TLS, forwards unencrypted to ingress service which then does dispatches.I've deployed ingres...
I managed to get this done largely using the ingress here:https://github.com/kubernetes/kops/tree/master/addons/ingress-nginxexcept for the ingress service I addedservice.beta.kubernetes.io/aws-load-balancer-ssl-certannotation pointing to my certificate ARN and settargetPortof both the ports to 80
How to update internal state of nginx' module runtime?
Lets suppose I wish to write a nginx module that blocks clients by IP. In order to do so, on initialization stage i read a file with IP addresses that I have to block (black list) and store it in module's context.Now I wish to update the black list without restarting nginx. One of the possible solutions, is to add a...
If you're able to move the black list outside of the module's context, perhaps to a system file, a KV store, or SHM, that would allow each process to talk to a central source blacklist. I believe shmat() and futex will do the job and the overhead will be negligible.
curl with `-k` and without `-k`
When I am opening a url usingcurlwithout-k, my request is passing and I am able to see the expected result.$ curl -vvv https://MYHOSTNAME/wex/archive.info -A SUKU$RANDOM * Trying 10.38.202.192... * Connected to MYHOSTNAME (10.38.202.192) port 443 (#0) * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 *...
For troubleshooting this kind of problem, the--resolveoptioncan be useful:curl -k -I --resolve www.example.com:80:192.0.2.1 https://www.example.com/Provide a custom address for a specific host and port pair. Using this, you can make the curl requests(s) use a specified address and prevent the otherwise normally res...
Docker: LetsEncrypt for development of "Https everywhere"
During development, test, and staging, we have a variety of docker servers that come and go as virtual machines. Eventually, the docker images under this process will get to a customer machine with a well-defined host and domain names. However, until that point all the machines are only our internal network. In the ...
I suggest you forget about Letsencrypt. The value proposition of that service is really focused on "getting that green lock in the browser", which you explicitly say you don't require.Also, Letsencrypt requires access to your server to verify that the ACME challenge file is there, which means YES, you need every such s...
Access Kubernetes Git Container via Ingress via HTTP as well as SSH
I have a small kubernetes (1.3) cluster (basically one node) and would like to install gogs in there. Gogs is "installed" using Helm. I do have the following templates in my helm chart:Deployment (using image gogs:0.9.97, having containerPort 3000 (http) as well as 2222 (ssh)Ingress (this is only for Port 80)Service (P...
Answering my own question. This issue is rather a configuration problem and caused by my own fault.Basically I haven't posted the ReplicationController of the Nginx-Ingress Resource. This one was missing the port 2222. so now it does look like:apiVersion: v1 kind: ReplicationController metadata: name: {{ template "fu...
Why not run uwsgi instances as root
I am reading through the uWSGI documentation and it warns toalways avoid running your uWSGI instances as root. What is the reason behind this?Does it matter if it is the only process (besides nginx) running in a docker container, serving up a flask application?
In general, security reasoning says that running as root as bad. If there were any kind of bug, for example a code execution bug that can allow anybody to execute arbitrary code they would be able to destroy your entire system.If you don't run the process as root, any code execution vulnerabilities would need to be pai...
Nginx caching: tag-based cache-busting like Varnish Hashtwo
We're about to set up a cache and reverse proxy for our site, and we're deciding whether to use Varnish or Nginx. We have complex cache-busting requirements, and we effectively require surrogate key (or tag-based) cache invalidation.Varnish offersHashtwowith this functionality. Does Nginx offer this in any form?
Nginx provides only thePurge methodfor invalidating cache which is only one of the four methods Varnish offers and not even the best option for your scenario.Moreover I strongly recommend Varnish over Nginx for caching web pages due to its specific nature of caching tool. Nginx could be pretty good at delivering static...
Atlassian Application Links Inside Docker
I have problems with this specific container configuration and make the Atlassian tools use their Application Links flawlessly.I have some atlassian applications running inside docker containers: Jira, Confluence, CrowdAll container are on the same server behind nginx:Nginx-> Confluence-> Jira-> CrowdI access the conta...
First I had to allow the Docker Bridge for my Docker Network to route traffic to the host. This is a bit cumbersome as the id for the network bridge for my Docker network is generated by Docker. I had to manually add a rule to iptables.I am using letsencrypt server certificates and the letsencrypt ca is not part of the...
Git repo structure with multiple docker files
What is the best way to structure a repository / project that has multipleDockerfilefor provisioning services.e.g.Dockerfile# build Nodejs app serverDockerfile# build Nginx forward proxyDockerfile# build Redis cache serverWhat is thebest practicesandstandardstructure within a repository to contain this information?
You generally have one folder per Dockerfile, as:each one can use multiple other resource files (config files, data files, ...) when doing their respectivedocker build -t xxx .each one can have its own.dockerignoreMyprojectb2d, for instance, has one Dockerfile per application:
Can shiny determine the use who logged in to nginx reverse proxy
I've successfully implemented an nginx reverse proxy for my shiny-server in order to have SSL and user authentication. However, there is still a gap that I can't figure out. Is there a way for my shiny app to determine which user is actually logged in?Here's my /etc/nginx/sites-available/defaultserver { listen 80; re...
Based on theShiny Docsthis a Shiny Server Professional feature only and you need to use the whitelist_headers directive to get those headers:4.9 Proxied Headers Typically, HTTP headers sent to Shiny Server will not be forwarded to the underlying Shiny application. However, Shiny Server Professional is able to forw...
Magento 2 in subfolder Nginx
Using Nginx 1.4.6 on Ubuntu, i'm trying to configure Magento 2 to run in a subfolder.I already have some others projets in/var/www, that are set up like so:server { server_name website.com; root /var/www/; location /p1/ { # config } location /p2/ { # config } }But now, my Mage...
As @Memes pointed out, I made a mistake in my location block:location /demos/demo-magento2/ { set $MAGE_ROOT /mnt/storage/demo-magento2/; set $MAGE_MODE developers; include /mnt/storage/demo-magento2/nginx.conf.sample; }Should be:location /demos/demo-magento2/ { set $MAGE_ROOT /mnt/storage/demo/demo-magento2/; ...
Asynchronous duplication request with nginx
How I can duplicate (or create and send) a request with the nginx web server. I can't usepost_action, because it is a synchronous method. Also, I compiled nginx with Lua support, but if I try to usehttp.requestwithngx.thread.spawnorcoroutine, I find the request has been executed synchronously. How do I solve this?locat...
ngx.thread.spawn not working, only this code worked:access_by_lua ' local socket = require "socket" local conn = socket.tcp() conn:connect("10.10.1.1", 2015) conn:send("GET /lua_async HTTP/1.1\\n\\n") conn:close() ';
Docker-compose: nginx does not work with django and gunicorn
I've been trying to set up an environment in docker-compose where there are several containers:DjangoNginxPostgresDbDataStorageI've used the following configuration:app: restart: always build: src expose: - "8000" links: - postgres:postgres volumes_from: - storage_files_1 env_file: .env comman...
It turned out that Gunicorn was the culprit. Putting its configuration into a file resolved the issue.gunicorn_config.py put in the same folder as manage.py:bind = "0.0.0.0:8000" loglevel = "INFO" workers = "4" reload = True errorlog = "/var/log/gunicorn/error.log" accesslog = "/var/log/gunicorn/access.log"And some ch...
Stop a Nginx Docker container
I am trying to stop a Docker container running Nginx only after there has been no activity in the access.log of that Nginx instance for a period of time.Is it possible to stop a Docker container from inside the container? The other solution I can think of is to have a cron running on the host OS that checks the/var/lib...
The docker container stops when the main process in the container stops.I setup a little dockerfile and a start script to show how this could work in your case:DockerfileFROM nginx COPY start.sh / CMD ["/start.sh"]start.sh#!/bin/bash nginx & sleep 20 # replace sleep 20 with your test of inactivity nginx stopBuild cont...
nginx http auth request module will only return default error pages
I am using nginx as a single point of entry to my entire solution.my goal is to send some url to be authenticated before continuing.I have found a module named:ngx_http_auth_request_modulewhich suits right in place to solve my problem.http://nginx.org/en/docs/http/ngx_http_auth_request_module.htmli am compiling my ngin...
auth_request is just for authentication. This little hack should work for youerror_page 401 /auth;After auth error it'll go to /auth location again, this time as ordinary request.
Changing Nginx Log File Location
I can't get any changes in the /etc/nginx/nginx.conf http block to be used. I'm starting with the simplest thing - I want to modify the name of access.log to something else (ie a.log). It is a vanilla nginx install (no custom config files yet). Here's what I know:changing a value in the head of nginx.conf does affect ...
Isn't your access_log also defined in a server block ? Have a look at the default config in nginx/sites-enabled/. In this case the value in http block is overwritten by the one in the lower block.
nginx rewrite - proxy if file not exists
I have a local directory (uploads) and anS3bucket setup. when the user is uploading an image the file is stored on the local directory:/uploads/member_id/image_nameand after 30 minutes the system is uploading the files toS3with the same path:s3.amazonaws.com/bucket/member_id/image_name;I have setup this rewrite rule on...
You should adjust yourlocationblock to use a combination of arewriteand aproxy_passdirective, such that each request is rewritten dynamically. As your configuration stands, the variables don't appear to be resolved on a per-request basis - according toNginx's documentation, only the server name, port, and URI can be s...
How bottle return binary files
I want to makebottlepython web service to serve binary files like pdf, picture and exe with authentication.Is it possible to serve all this files using bottle? I have hard time finding a tutorial for that.How about theperformance? Does bottle python handle hundreds of thousands downloads simultaneously?I am planning to...
It is definately possible to serve these files using bottle. You simply serve them as static files. As far as authentication goes, I do not believe bottle comes with authentication support ( as far as I know ). When it comes to performance though, this is an area when it really depends on how you deploy it. In a regula...
nginx: Is it possible to have an 'catch all' error_page?
When looking at the documentation for nginx'serror_pagedirective, it seems that one has to manually list out every possible status code that nginx (or an upstream server) could return.For example:error_page 404 /404.html; error_page 502 503 504 /50x.html; error_page 403 http://example.com/forbi...
It is not possible.Moreover, it is not recommended to blindly list all codes, asnginx allows to redefine all response codes, including ones you don't really want to redefine except in a few very specific situations (e.g. you don't normally want to redefine 304 (Not Modified), and probably not 302 (Found) unless there a...
Nginx – read value from redis and store it into variable
Is there any way to read redis value and store it into nginx variable?I want to use it for multi-domain website, where subdomains will point to different IPs. All the subdomains will be stored in redis like this:"subdomain" => "address_for_proxy_pass"So what I need is to parse subdomain (done), store it into variable (...
set_by_lua+ngx.location.capture?
Why does listen `443 default_server ssl` work for multiple server names in nginx?
I run nginx for static content and as a proxy to Apache/mod_wsgi serving django. I have example.com and test.example.com as proxy to Apache/Django and static.example.com which serves all static files directly through nginx. I have a wildcard SSL cert so that each of these sub-domains can use SSL (and I only have one IP...
The SSL protocol by itself (without theSNIextension) uses the ip address of the server to request the SSL certificate. With SNI it also passes the hostname (doesn't work for Win XP), but that should't be relevant here.Server directives are not an exact match. It's the "closest" match. It may appear "work", but it may b...
Rails ignoring config.action_dispatch.x_sendfile_header? Using Thin + Nginx
I've set up a production environment running Rails 3.1.0rc6, Thin and Nginx.For some reason, having setconfig.action_dispatch.x_sendfile_header = "X-Accel-Redirect"inconfig/environments/production.rb, Rails seems to have completely ignored it; assets aren't being served, and the response headers for one file is as foll...
I came across this inproduction.log:Started GET "/assets/bg-linen-light.png" for ***** at 2011-08-28 11:04:42 +0400 Served asset /bg-linen-light.png - 304 Not Modified (102ms)The problem is that the browser had requested that filebeforex_sendfile_headerwas changed to what it should be, so it seems that Rails (and/or th...
node.js server to return /, static files from /public/ via nginx?
i'm having a little issue with Rasmus Andersson awesome node.js EC2 templatehttp://rsms.me/2011/03/23/ec2-wep-app-template.htmlok, the issue isi would like the root urlhttp://www.mydomain.com/response to be delivered by the node.js server (which listens on port 3000)nginx should still deliver everything static from /p...
i'm answering this question myself as i found the solution after a lot of "oh my ...... ... i can't believe this does not work". what was missing in my case, waserror_page 403 = @backend;in the main server block, as a request for / did not return an http 404 (file not found), but an http 403 (no access).the issue was s...
What is the equivalent value for apache configuration
I need to convert following nginx rule to Apache configuration. can anyone help me.location /chat { rewrite /chat(/.+)$ $1 break; proxy_pass http://localhost:8000; proxy_set_header Host $host; proxy_set_header Cookie $http_cookie; proxy_buffering off; proxy_send_timeout 310; ...
Have a look at themod_proxy documentation, I think theProxyPassMatchdirective is of interest.
Is there a way to run some script before the upload starts in php?
Can you run some script before the uploading of a file starts in php? Example, I'm POSTing to upload.php, and in that file I want to check their $_SESSION first before I start wasting bandwidth on them and the file stats uploading to my server. I'm using php 5.2.11 on nginx.
No. The request doesn't get to the PHP engine until after the file has been uploaded.
NGINX add two variable/arguments numbers
I'm trying to set up an Nginx, where I want to add two numbers together.server { server_name "~^pr-(\d*).review-apps.example.com$"; location / { set $port 50000+$1; proxy_pass "http://localhost:$port/test"; } }But this doesn't work 🙄. (Result is in string. F...
If you use fixed length numbers, for example only three digits, for this particular case you can use string concatenation instead of adding numbers:server { server_name "~^pr-(\d{3}).review-apps.example.com$"; location / { set $port 50$1; proxy_pass "http://localhost:$port/test"; } ...
Is nginx needed if Express used
I have a nodeJS web application with Express running on a Digital Ocean droplet.The nodeJs application provides back-end API's. I have two react front-ends that utilise the API's with different domains. The front-ends can be hosted on the same server, but my developer tells me I should use another server to host the fr...
This is a way too open-ended question but I will try to answer it:In terms of security could someone tell me If I need nginx, and my options please?You will need Nginx (or Apache) on both scenarios. With one or multiple servers, using Express or not, Express is only an application framework to build routes but you stil...
Trouble with deploy django channels using Daphne and Nginx
I got a 502 error when I'm trying to open a website. I used the instructions from the official websitelinkAdded new file lifeline.conf at/etc/supervisor/conf.d/lifeline.conf[fcgi-program:asgi] # TCP socket used by Nginx backend upstream socket=tcp://localhost:8000 # Directory where your site's project files are locate...
I am assuming you are not passing asgi application to daphne, because configuration you pasted in question has missing line. You have to pass it correctly. Assuming you have confpackagewithasgi.pymodule inside it containing asgi application instance, you have to docommand=/home/ubuntu/Env/lifeline/bin/daphne -u /run/da...