Prompt stringlengths 14 160 | Instruction stringlengths 18 2k | Response stringlengths 8 2k |
|---|---|---|
nginx proxy pass to external url | I have configured my nginx on amazon ec2 for the urlwww.example1.com. I need to proxy passwww.example1.com/blogto my blogging hostwww.example2.com/blogwhich is hosted on bluehost ( shred hosting ) without changing the url in browser. Is it possible ?I tried many different combinations likelocation /blog {
proxy_pas... | The problem is because $http_host inproxy_set_header Host $http_host;uses the host in your original request header, but what you really need is the host forwww.example2.com. $proxy_host will use the host in yourproxy_passdirective. seeEmbedded Variablesat the bottomhttp://nginx.org/en/docs/http/ngx_http_proxy_module.ht... |
Rewriting nginx for pushState-URL's | I am trying to getnginxto work with mypushState-based URI handling thatbackbone.jsmanages for me in an Javascript app.Right now accessing URI's with one level, eg.example.com/usersworks well, but not two-level or deeper URI's, such asexample.com/users/all, which is mentioned in theBackbone documentation:For example, if... | Here is what i did to my application. Every route ending with a '/' (except the root it self) will serveindex.html:location ~ ^/.+/$ {
rewrite .* /index.html last;
}You can also prefix your route :Backbone.history.start({pushState: true, root: "/prefix/"})and then :location ~ ^/prefix/ {
rewrite .* /index.htm... |
nginx: "/root/index.html" forbidden (13: Permission denied) | I am installing nginx. Here is the steps I followed:Make index.html file in /root directoryedit /etc/nginx/nginx.conf. After edit it looks like this:user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
...
http {
...
server {
listen 80 default_server;
server_name my_dom... | Oh! Pleasedon't disable SELinux.Don't use/root— it's a trap!First — do youreallyneed to serve files from/root? That's actually the home directory for the rootuser account, not meant to be thewebroot.Instead, use/var/www/htmlor (my preference)/srv/www.If youdouse/root, make sure you're not exposing ssh keys orauthorized... |
Nginx doesn't serve static | I'm running Django on Ubuntu Server 9.04.Django works well, but nginx doesn't return static files - always 404.Here's the config:server {
listen 80;
server_name localhost;
#site_media - folder in uri for static files
location /static {
root /home/user/www/oil/oil_database/static_files;
... | How is your directory setup? Do you have a folderstaticin/home/user/www/oil/oil_database/static_files? In that case, the directive should look like this (note the trailing slash in/static/):location /static/ {
autoindex on;
root /home/user/www/oil/oil_database/static_files;
}If you want to map the path/home... |
How to intentionally cause a 400 Bad Request in Python/Flask? | A consumer of my REST API says that on occasion I am returning a400 Bad Request-The request sent by the client was syntactically incorrect.error.My application (Python/Flask) logs don't seem to be capturing this, and neither do my webserver/Nginx logs.Edit: I would like to try to cause a 400 bad request in Flask for de... | You can useabortto raise an HTTP error by status code.from flask import abort
@app.route('/badrequest400')
def bad_request():
abort(400) |
nginx: [emerg] unknown directive " " in /etc/nginx/sites-enabled/example.com:3 | I have followed this websitehttp://raspberrypihelp.net/tutorials/24-raspberry-pi-webserverto setup the HTTP server nginx on my Raspberry Pi and try to setup a site callexample.com. But when I runsudo service nginx restart, it saidRestarting nginx: nginx: [emerg] unknown directive " " in /etc/nginx/sites-enabled/example... | I had the same problem which was that I copy/pasted the config code from the web and some dirtyEOL(end of line) characters where there.The editor didn't show them, butnginxtreated them like a directive.Just deleted everyEOLand added again. |
Http POST drops port in URL | I have a webapp built with Django. I'm currently running it off a laptop at home behind a router.I have the router configured to route all traffic sent to a specific port to that laptop.I have Nginx as a reverse proxy for Apache, using mod_wsgi to run Django.My problem is this: when I try to submit any POST form, the p... | I have the same problem with my development server.
After some internet search I've found this discussion (nginx, apache, and odd admin error) where the solution is to modify the proxy configuration of nginx.The configuration setting to modify is:proxy_set_header Host $host;the solution is to add the port nu... |
Gunicorn failed to load Flask application | I have a Flask app I am trying to serve via Gunicorn.I am using virtualenv and python3. If I activate my venv cd to my app base dir then run:gunicorn mysite:appI get:Starting gunicorn
Listening at http://127.0.0.1:8000
DEBUG:mysite.settings:>>Config()
...
Failed to find application: 'mysite'
Worker exiting
Shutting dow... | You're pointing gunicorn atmysite:app, which is equivalent tofrom mysite import app. However, there is noappobject in the top (__init__.py) level import ofmysite. Tell gunicorn to call the factory.gunicorn "mysite:create_app()"You can pass arguments to the call as well.gunicorn "mysite:create_app('production')"Intern... |
RabbitMQ error timeout | I've set up RabbitMQ in order to parse some 20.000 requests from an external API but it keeps timing out after a few minutes. It does get to correctly parse about 2000 out of the total 20.000 requests.The log file says:=INFO REPORT==== 16-Feb-2016::17:02:50 ===
accepting AMQP connection <0.1648.0> (127.0.0.1:33091 -> 1... | I've just solved a similar problem in python. In my case, it was solved by reducing the prefetch count on the consumer, so that it had fewer messages queued up in its receive buffer.My theory is that the receive buffer on the consumer gets full, and then RMQ tries to write some other message to the consumer's socket an... |
Sidekiq worker not getting triggered | I am usingSidekiqfor my background jobs:I have a worker app/workers/data_import_worker.rbclass DataImportWorker
include Sidekiq::Worker
sidekiq_options retry: false
def perform(job_id,file_name)
begin
#Some logic in it .....
end
endCalled from a file lib/parse_excel.rbdef parse_raw_data
#job_id an... | I had a similar problem where Sidekiq was running but when I calledperform_asyncit didn't do anything except returntrue.The problem wasrspec-sidekiqwas added to my ":development, :test" group. I fixed the problem by movingrspec-sidekiqto the ":test" group only. |
Nginx unknown directive for passenger_root | I'm running into an error when I try to restart the server. I don't know how to fix this.deploy@user:~$ sudo nginx -s reload
nginx: [emerg] unknown directive "passenger_root" in /etc/nginx/nginx.conf:66I added these lines to the nginx configuration file '/etc/nginx/nginx.conf'passenger_root /home/deploy/.rvm/gems/ruby-... | I ran into the same thing. I had accidentally installed the nginx-extras package that is normally provided by Ubuntu, rather than the one provided by Phusion Passenger's repository. The Passenger package has Passenger compiled with Nginx as a module, while the other package does not.The solution is to add Phusion Passe... |
Set up nginx to allow cross-domain request for subdomain | I've got two domains:domain.com
sub.domain.comdomain.com needs to make an ajax request to sub.domain.com. I realize that the browser will block this if the request is hardcoded to be sub.domain.com. I tried the following nginx conf:server {
server_name domain.com;
rewrite ^/api/(.*)$ http://sub.domain.com/api/... | I think you need to create this inside the location or server blockserver {
server_name example.com;
add_header Access-Control-Allow-Origin sub.example.com; # < this is the needed header
# rest of the configuration
} |
Is it possible to change the HTTP status code returned when proxy_pass gateway is down in nginx? | For SEO purposes, we would like to change the HTTP status code returned whenever the backend machine behind nginx goes down for some reason.We would like to change this to "503 Service Unavailable". As well as provide a Retry-After header to indicated to Google / Bing that the request should be retried in X number of s... | I think youwillhave to set up a specific error page, however you can achieve what you're looking for if you do. Try this:location / {
proxy_pass http://backend;
proxy_intercept_errors on;
error_page 502 503 504 =503 @proxyisdown; # always reply with 503
}
location @proxyisdown {
add_header Retry-After ... |
how to "allow from hostname" in nginx config | I'm currently doing this in my nginx.conf:allow 1.2.3.4;
deny;What I'd really like to do is this:allow my.domain.name;
deny;I.e., I want nginx to do an A record lookup on my.domain.name at the time of the request, and if it matches the IP that the request is coming from, then allow it. I don't see any built-in mechanis... | There is no such feature in official distribution of nginx. Beacause it may heavily reduce performance.Third party moduleshttp://wiki.nginx.org/3rdPartyModulesalso doesn't contain this feature. |
How to serve GIT through HTTP via NGINX with user/password? | Despite all the links I've found on how to configure git/nginx to get my repos, I can't make them work.I followed this tutorial,Git repository over HTTP WebDAV with nginx, but the user/password restriction doesnt' work. Anyone can clone the repository.I'm from a configuration using SVN + Apache + DAV_SVN, with a file f... | Take a look at the following article,http://www.toofishes.net/blog/git-smart-http-transport-nginx/It provides a sample nginx config:http {
...
server {
listen 80;
server_name git.mydomain.com;
location ~ /git(/.*) {
# fcgiwrap is set up to listen on this host:port
... |
Error with IP and Nginx as reverse proxy | I configured my Nginx as simple reverse proxy.I'm just using basic settinglocation / {
proxy_pass foo.dnsalias.net;
proxy_pass_header Set-Cookie;
proxy_pass_header P3P;
}The problem is that after some time (few days) the site behind nginx become unaccessible. Indead nginx try to call a bad ip (the site behi... | If theproxy_passvalue doesn't contain variables, nginx will resolve domain names to IPs while loading the configuration and cache them until you restart/reload it. This is quite understandable from a performance point of view.But, in case of dynamic DNS record change, this may not be desired. So two options are availab... |
Where is the Phusion Passenger config file? | Where is the Apache module installed for Phusion Passenger? I want to adjust some of the config values found in "Configuring Phusion Passenger".I don't know where this config file is. I've installed everything like the documentation says for Nginx. | There's is a commandpassenger-config --rootwhich shows Passenger's root. All other config should be in the Apache or Nginx config file, which means insites-enabled/your_site. |
uwsgi + nginx + flask: upstream prematurely closed | I created an endpoint on my flask which generates a spreadsheet from a database query (remote db) and then sends it as a download in the browser. Flask doesn't throw any errors. Uwsgi doesn't complain.But when I check nginx's error.log I see a lot of2014/12/10 05:06:24 [error] 14084#0: *239436 upstream prematurely
cl... | Change nginx.conf to includesendfile on;
client_max_body_size 20M;
keepalive_timeout 0;See self answeruwsgi upstart on amazon linuxfor full example |
$http_origin in Nginx config files | I've seen it used in a lot of examples relating to CORS but where is the value of $http_origin set?I checked theNginx variablesbut there's no mention of it.
And there's no mention inPHP FastCGI. | $http_is automatically created based on the request headers. You can see the same onhttps://nginx.org/en/docs/http/ngx_http_core_module.html#var_http_$http_namearbitrary request header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores |
Restrict static file access to logged in users | I want to restrict files to be available to logged in users, but otherwise return a 403 error or similar. For example a user should be able to view/download/static/data/example.csvonly if they're logged in.I know how to control the actual displaying of the files using Flask-Login if they're not logged in, but not how ... | Flaskadds a static routeto serve static files. When you're in production, you typically "short circuit" this route so that Nginx serves the files before the request ever gets to your app. Instead of adding this "short circuit", leave it out and let Flask handle the requests. Overwrite the static route with one that ... |
How to configure IPython behind nginx in a subpath? | I've gotnginxrunning handling all SSL stuff and already proxying/to aRedmineinstance and/cito aJenkinsinstance.Now I want to serve anIPythoninstance on/ipythonthrough that very samenginx.Innginx.confI've added:http {
...
upstream ipython_server {
server 127.0.0.1:5001;
}
server {
listen... | I had the same problem. I updated nginx up to the current version (1.6.0). It seems to be working now.Server config:location /ipython {
proxy_pass http://ipython_server;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Origin "";... |
SaltStack: In a watch statement, how do I specify a directory where all files should be watched? | I would like the nginx service to restart whenever any file in the/etc/nginx/conf.ddirectory is created or modified.There are a number of files in that directory, and rather than specifying particular files, I would like to watch for all changes.I've tried this:nginx:
pkg.installed:
- name: nginx
service:
-... | I'm using a glob for matching:file: /etc/nginx/conf.d/*Here's the corrected snippet:nginx:
pkg.installed:
- name: nginx
service:
- running
- enable: True
- restart: True
- watch:
- file: /etc/nginx/nginx.conf
- file: /etc/nginx/conf.d/*
- pkg: nginxAlso do note that salt can on... |
How to simulate DDOS/Slashdotting? | So, I'd like to get more experience working with high-traffic websites, but unfortunately the Internet is not beating down the doors to my blog.How can I simulate tens/hundreds of hits per second on my blog and test its performance? I'm hosting my blog with an SSH account on a shared server. | You can send lots of requests to your server, using tools such as :absiegeJMeterThe first one, ab, will only allow you to send lots of a requests to a single URL -- which is great to benchmark a single script / page ; but doesn't reflect the real pattern of a user browsing your website(CSS/JS/images don't get loaded, f... |
What's the purpose of ppa:ondrej/nginx? | I've juste addppa:ondrej/phpon my ubuntu server, and it prompt me the message below.Why am I advised to addppa:ondrej/nginx(stable) too? What's the exact purpose of this?For information I have already installed Nginxfrom the official doc.$ sudo add-apt-repository ppa:ondrej/php
Note: PPA publishes dbgsym
You need to ... | According to thehomepageforppa:ondrej/nginx, here the PPA description:This branch follows latest NGINX Stable packages compiled against latest OpenSSL for HTTP/2 and TLS 1.3 support.
BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reporting
PLEASE READ: If you like my work and want to give ... |
How to deploy a finished nuxt.js app to a webserver? | At work, I got some little insight to nuxtjs development and I got very interested in it. So, I started developing on my own a little bit, but now, I'm stuck with my finished project.To develop, I spin up a local server with "npm run dev" in my CLI. This all works fine.But, how do I deploy my now finished project to ru... | The simplest way - you need to generate all the content:Runnpm run generate.Go to thedistsubfolder of your project and copy all from there to some public hosting, like GitHub Pages.Though if you have some content depended from the user, you need to deploy it as a SPA:Changemodeinnuxt.config.jstospa.Runnpm run build.Dep... |
You have already activated rack 1.6.0, but your Gemfile requires rack 1.6.4 | Similar toproblem with rack 1.3.2. You have already activated rack 1.3.2, but your Gemfile requires rack 1.2.3-- I'm experiencingYou have already activated rack 1.6.0, but your Gemfile requires rack 1.6.4when attempting to run Rails (4.2) in production with Puma and Nginx.bundle update rakenorrm Gemfile.lock && bundle ... | you need to uninstall one version of rack which is not required.Do this pleasegem uninstall rack -v 1.6.0Reference:How to force rack to work around the usual "You have already activated rack..." bug? |
Send additional header to FastCGI backend with nginx | I use nginx with several fastcgi backends (php-cgi, mod-mono-fastcgi4). Now I need to sent an additional http header to the fastcgi backend, basically the same as proxy_set_header does when using nginx as reverse proxy. But to my findings, there is no such thing as fastcgi_set_header in nginx.Somebody got any ideas how... | I took a quick look at the manual and I think the closest you will find is passing fastcgi parameters:The request headers are transferred to the FastCGI-server in the form of parameters. In the applications and the scripts run from the FastCGI-server, these parameters are usually accessible in the form of environment v... |
Running a flask app with nginx and gunicorn | I'm new at this and have only been using nginx to serve static files. I have now installed flask and gunicorn. If I rungunicorn -b 127.0.0.2:8000 hello:appand then wget it from the server it works well. If I try to access it from a browser, however, it returns a 404 error (I am running this on a server that hosts a wor... | This is how I serve my flask apps in Nginx:Run gunicorn daemonized using a socket:sudo gunicorn app:app --bind unix:/tmp/gunicorn_flask.sock -w 4 -DRelated nginx config:upstream flask_server {
# swap the commented lines below to switch between socket and port
server unix:/tmp/gunicorn_flask.sock fail_ti... |
Is it possible to seamlessly redirect websockets? | I know that it is possible to pass requests through the reverse proxy (like Nginx, HAproxy and so on) but I need to redirect requests to another public server in the same domain suffix. I.e. fromwss://example.comtowss://ws1.example.com.Here is an example:I need to redirect requests from Nginx or Java.
Is to possible to... | Per thewebSocket specification:Once the client's opening handshake has been sent, the client MUST wait for a response from the server before sending any further data. The client MUST validate the server's response as follows:If the status code received from the server is not 101, the
client handles the response per HT... |
Resource temporarily unavailable using uwsgi + nginx | I've django app host using nignx-uwsgi. Here is my uwsgi configuration:[uwsgi]
master = true
socket = /var/uwsgi/uwsgi.sock
chmod-socket = 666
chdir = /home/ubuntu/test
wsgi-file = /home/ubuntu/test/test/wsgi.py
virtualenv = /home/ubuntu/virtual
vacuum = true
... | This error comes when there is a heavy load on the server. First I had tried by increasing the value of worker_connections but it didn't work. Queue size for uWSGI is by default 100, so when more than 100 requests from Nginx to uWSGI is passed, queue get full and Nginx throws 502 to the client, to solve this increase t... |
Setting up Laravel with Nginx | I'm attempting to set up theLaravelPHP Framework to work withNginx. Here is my directory structure:/project
/application
/laravel
/public
index.php
/legacy
/index.php
/stylesheets
default.cssBasically what I have is a standardLaraveldownload w/ alegacyfolder thrown in which holds ... | server {
server_name .laravel.dev;
root /home/tamer/code/laravel/public;
index index.php index.html;
#browse folders if no index file
autoindex on;
# serve static files directly
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
... |
What is fastcgi_index in nginx used for? | On many sites can be found this nginxlocationblock :location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000
fastcgi_index index.php
...
}Given theofficial documentationoffastcgi_index, it seems like it is used when requests end with/. However, it doesn't match the regular expression of thelocationblock above? Am I ... | You are right, if your nginx configuration (outside thelocationdirective) has noindexdirective, then thelocationdirective will never match and thefastcgi_indexdirective is useless.If you have a line like this on your configurationindex index.phpthen a request to/will create an internal redirect to/index.php, thelocatio... |
Serving static files with nginx located in another docker container | Just to start off, I have seenthis. But he/she usesbuild, and I useimage.I have a docker-compose file that pulls an image that I have made previously onto my server.app:
restart: always
image: some-app-image:latestnginx configlocation /static/ {
root /data/app/web_interface; <--- this exists in some-app-image ... | All the ideas I've had in the past:Sharing a docker volume from app to nginxYou can make a volume in the app'sDockefileand copy in the staticfiles when the container runs. Then share the volume with nginx container usingvolumes_from. This is kind of ugly and doesn't work at all if your appdepends_onnginx. I'd say this ... |
Logging from multiprocess docker containers | I'm using the nginx method of symlinking linking to /dev/stdout for any log files that I want to appear in 'docker logs', however this is not working.I have tested this with a simple cronjob in /etc/crontab, if a symlink is present (pointing to /dev/stdout) it doesn't write anything (as far as I can tell), but if I del... | End result is that the /dev/stdout for the cron job was pointed to the different device./proc/self/fd/1 and should have been /proc/1/fd/1 because as docker only expects one process to be running this is the only stdout it monitors.So once I had modified the symlinks to point at /proc/1/fd/1 it should have worked howeve... |
How to reinstall nginx if I deleted /etc/nginx folder (Ubuntu 14.04)? | I'm trying to reinstall nginx, but I have thisnginx -t
nginx: [alert] could not open error log file: open()
"/var/log/nginx/error.log" failed (2: No such file or directory)
2015/01/25 16:18:01 [emerg] 1400#0: open() "/etc/nginx/nginx.conf"
failed (2: No such file or directory)
nginx: configuration file /etc/ngi... | Try:sudo aptitude purge nginx && sudo aptitude install nginxThis code will remove and reinstall Nginx |
production.log empty on Rails 4 / Capistrano / Passenger / Nginx server (digital ocean) | I have set up a rails 4 server on Ubuntu 12.04 using Capistrano, Nginx, Passenger, Postgres, Redis/ResqueEverything is working great, except that the production.log file is always empty.I have tried a variety of configuration changes in production.rb to no avail.It's definitely not a permissions issue, as the permissio... | The culprit wasHeroku's rails_12factorgemRemoving that gem from the Gemfile, now the logs are working as expected.# group :production do
# gem 'rails_12factor'
# end |
Redirecting a subdomain with a regular expression in nginx | The nginx documentation says that theserver_name directivesupports regular expressions. I've been banging my head against the wall trying to get even a trivial regex working.I wanthttp://subdomain.mydomain.comto redirect tohttp://mydomain.com/subdomainHere is my code.server {
server_name "~^subdomain\.mydomain\.com$"... | To answer an old question to help othersusing nginx 1.1.19 you can do the following:server {
server_name ~^(?\w+)\.domainA\.com$;
location / {
rewrite ^ https://$subdomain.domainB.com$request_uri permanent;
}
}The subdomain before domainA.com is matched and stored in variable $subdomain whi... |
log_format in nginx.conf being ignored | Total NGINX beginner here.My logs currently look like:92.21.236.47 - - [08/Jan/2017:00:48:10 +0000] "GET / HTTP/1.1" 200 148 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"When I add the following line in the default /etc/nginx/nginx.conflog_format main '$remote_addr - $remote_user xxx[$... | changing ..access_log /var/log/nginx/access.log;to ..access_log /var/log/nginx/access.log main;fixed it.wheremainis the name of the log_format as defined at ..log_format main '$remote_addr - $remote_user xxx[$time_local]xxx '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http... |
Nginx overwrites general symfony errors with 502 Bad Gateway | When I try to access a non-existing route or make a mistake inside a Twig template, instead of getting the Symfony error page with debug information, I get redirected to a default nginx 502 Bad Gateway.The log shows an interesting line:013/07/17 16:11:41 [error] 16952#0: *187 upstream sent too big header while reading
... | Increase your buffer size in nginx configuration and restart nginx afterwards as suggestedhere.proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;Further increase the fastcgi buffer in the php section of your configuration ( location ~ .php$ )fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fas... |
How to Serve HTML Files from a Nginx Server Using Docker | ProblemI have a Nginx container running in docker. It's configured to listen to porthttp://localhost:80. When I type the url to my browser I get the following...Welcome to nginx!If you see this page, the nginx web server is successfully installed and working. Further configuration is required.For online documentation a... | The default directory that static assets are served out of is/usr/share/nginx/html, not/var/wwwin theOfficial NGINX Docker image.With that said, you're also mapping your entire root directory and not the/public/folder where your folder contents live - unless of course you're running this from that directory on a pre-bu... |
nginx unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/default:20 over Raspbian | I'm new at nginx and Raspberry.I installed nginx usingsudo apt-get installAnd everything was fine at that point. The problem came when I tried to restart nginx, It threw this errorJob for nginx.service failed. See 'systemctl status ngins.service' and 'journaldtl -xn' for detailsAfter an investigation I found that the p... | I had the same issue.
Confirmed there was a missing;at the end of a new added line inside the server block{...}.Ensure the curly braces and;areall in place.For example line like this will give error,server_name localhostAdding ';' to end like this will fix itserver_name localhost; |
nginx: which port received the request? | For testing purposes, I am using nginx to listen on multiple ports when I send distributed http requests. I can see the request be received by nginx - but I need to know which of its ports actually got it. I can't see any options in the logs to flag this.I guess an ugly alternative is to install multiple instances so t... | Anything you can access as a variable in nginx config, you can log, including non-standard http headers, etc.The var you want to add is$server_portlog_format mycustomformat '$host $remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$... |
Status Code 460 on Application Load Balancer | I'm seeing a concerning amount of460status codes in the logs of my Application Load Balancer. I don't see any patterns on these codes in regards to times, servers, or request URLs. According tothis forum post, the 460 means:The client has closed the connection with the ALB before the idle
timeout has kicked in on eit... | The documentation for the status code 460 is updated for Application Load Balancers.This error occurs when the load balancer received a request from a
client, but the client closed the connection with the load balancer
before the idle timeout period elapses.Check whether the client timeout period is greater than th... |
Error: No module named staticfiles | I'm newbie with django, I'm trying to deploy my project on a production server but I'm getting this error:Error: No module named staticfilesWhen trying to start the server:python manage.py runfcgi host=127.0.0.1 port=8081 --settings=settingswith the fastCGI + nginxAny idea?Thanks! | I just remove the whole server and installed everything again, that solved everything. Seems I got some old django ghost installation or somethingSorry and thanks! |
Nginx config: how to use auth_basic authentication if ssl_client_certificate none provided? | I'm trying to set up Nginx server as follows:First, the server should check whether the user provides the client SSL certificate (viassl_client_certificate).
If the SSL certificate is provided, then give access to the site,If the SSL certificate is NOT provided, then ask the user to enter a password and logs throughaut... | You can setauth_basicconfiguration in theifclause like this:server {
listen 443;
auth_basic_user_file .htpasswd;
ssl_client_certificate ca.cert;
ssl_verify_client optional;
...
location / {
...
if ($ssl_client_verify = SUCCESS) {
set $auth_basic off;
}
... |
Session cache not detected in nginx | SSLlabs still show the following message even after i added thessl_session_cacheSession resumption (caching) No (IDs assigned but not accepted)Here is my full configurationserver {
listen 443 spdy; #Change to 443 when SSL is on
ssl on;
ssl_certificate /etc/ssl/domain.com_bundle.crt;
ssl_ce... | SSL Labs doesn't assume thatSNIis available to the client, so it only tests the default virtual server.The problem could be that you don't have SSL session caching enabled on the default server. To enable it, you just need to add thatssl_session_cacheline to yourdefault_server. Alternatively, if you'd like that configu... |
How to disable output buffering in nginx for PHP application | We have code similar to this:In Apache, this would send each echo to the browser as it was output. In nginx/FastCGI however, this doesn't work due to the way nginx works (by default).Is it possible to make this work on nginx/FastCGI, and if so, how? | First php has to correctly flush everything :@ob_end_flush();
@flush();Then, I found two working solutions:1) Via Nginx configuration:fastcgi_buffering off;2) Via HTTP header in the php codeheader('X-Accel-Buffering: no'); |
Testing nginx without domain name | I'm working throughhttps://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04. I've reached the end of the tut and started both uwsgi and nginx as directed.
I have been able to get all steps working including uwsgi as far as I am aware.My test django site is ... | You can just use your VPS's ip in place of "sample.com":server {
listen 80;
server_name ;
}If you haven't already, you may want to assign a static IP; I believe Digital Ocean gives you some free ones. |
Nginx variable for subdomain? | I need a Guru's advice.On Nginx'sconffile, I would like to get the subdomain as a variable in order to redirect accesses as follow.ACCESS:http://userX.example.com/?hoo=barREDIRECT:http://example.com/userX/?hoo=barBut I getREDIRECT:http://example.com/userX.example.com/?hoo=barMy current_http.confsettings are like below.... | You can use a regular expression in theserver_nameto extract the part you need as a named capture. For example:server {
listen 80;
server_name ~^(?.+)\.example\.com$;
return 301 http://example.com/$name$request_uri;
}Seethis documentfor more. |
When using htop command, do red values in the time+ column mean there's something wrong? | Below is my serverhtopdisplay. Thenginxprocess uses CPU time more then 18 hours, and is shown in red color, but CPU and memory all look OK. Is the value within the normal range? | I was curious about this too, so I dug into the source code and found this:if (hours >= 100) {
snprintf(buffer, 10, "%7lluh ", hours);
RichString_append(str, CRT_colors[LARGE_NUMBER], buffer);
} else {
if (hours) {
snprintf(buffer, 10, "%2lluh", hours);
RichString_append(str, CRT_colors[LARGE_NUMBE... |
502 Bad Gateway error for my server running with Node JS on nginx proxy | I am getting 502 bad gateway error: when I check the nginx error log I find this:2017/05/06 02:36:04 [error] 48176#0: *135 connect() failed (111: Connection refused) while connecting to upstream, client: 10.163.XX.X, server: abc-def-ghi, request: "GET /favicon.ico HTTP/1.1", upstream: "https://127.0.0.1:5300/favicon.ic... | 502 errors are generally caused by NGINX being unable to pass a request to "upstream", in this case your Node.js server (which is also what the error message suggests:"Connection refused"").It may be crashing and restarting, so check its logfiles to see what's causing the crashes. |
Nginx: When the `index` and `try_files` in the same block, why the `try_files` will be processed, not the `index` directive? | The nginx.conf is as following:http {
server {
listen 8080;
server_name example.com;
root /tmp/test/example;
location / {
index index.html;
try_files $uri /test.html;
}
}
}When I accessexample.com:8080, it accesses the/tmp/test/examp... | Thetry_filesdirective isdocumented here.It specifically documents twofileelements:$uriand$uri/. The first tests for the presence of normal files and the second for the presence of directories.Theindexdirective is invoked as a consequence of processing a URI which points to a directory which contains a file matching one... |
unwanted HTTPS -> HTTP redirects with nginx + uwsgi + flask app | I have aflaskapp, hosted byuwsgi, withnginxas a reverse proxy to uwsgi, using the built-inuwsgi proxy module. Whenever I visit a page that redirects to another page, the Location header points to a non-HTTPS URL. For example:$ socat openssl:my-web-server:443 stdio
GET / HTTP/1.0
Host: my-web-server
HTTP/1.1 302 FOUN... | uwsgi needs to be passed the scheme (http or https) used to serve the request in order to write the correct Location header.By default a bunch of settings are set in the/etc/nginx/uwsgi_paramsfile. Theinclude uwsgi_params;line in the config file is what load these.For whatever reason, though, the scheme is not one of ... |
Connect to unix:/var/run/php5-fpm.sock failed. What is wrong with my setup? | I have a 2GB VPS on DigitalOcean and I am hosting WordPress 3.9.1 under Debian 7 with NGINX, php-fpm and unix socket.It was working perfectly until last week it started showing a "502 bad gateway" error. I checked the logs and found that:php5-fpm log is showing pm.max_children was reached and
nginx log is showing the... | The first problem is you are specifying 100 max_children, that is awfully high for 2GB. I would drop it to 25 children. See my post here on how to optimise your php-fpm configuration for your setup:WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawningAlso, usi... |
uwsgi installation error in windows 7 | Trying to install uwsgi according todocumentation.I'm getting the below error on Windows 7.What should I do?(uwsgi-tutorial) C:\Users\Home\Videos\uwsgi-tutorial\mysite>pip install uwsgi
Collecting uwsgi
Using cached uwsgi-2.0.11.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call... | uWSGIcan be compiled on Windows only usingcygwin. There is no such thing asunamein normal Windows console, but it exists insidecygwin. If you're already in cygwin console, try to rununamecommand, if that exists, check ifos.uname()in python insidecygwinis also working. |
Setting up Nginx on a new micro-instance on AWS | I'm trying to figure out how to set up Nginx on a micro-instance on AWS.The micro-instance is set up and running. I've associated an elastic IP to it. I SSH into it, make a new user runapt-get upgrade, thenapt-get install nginx. Nginx gets installed. Then I runsudo service nginx start. It looks like nginx is started. I... | To verify that the problem isn't with the server, try running awget http://localhost/from your instance and see if you get the page you're expecting. If you do, it's probably firewall related.When you created your instance, you had to provide a security key (this is what you use to ssh into it) and a security group.Yo... |
Nginx redirect if cookie present | I've seen some limited resources on checking for cookies with Nginx, but I couldn't really find the answer I was looking for, hopefully some of you Nginx masters can give me a hand.Essentially I have a vhost that I'd like to redirect to a different domain unless the user has a cookie, here is what I've created:server {... | That makes sense.
I would define another virtual host (beta.example.com) with that different root folder
and upon encountering cookie - do a rewriteYou can't set different roots for a domain conditionally, but you can redirect (rewrite) to another domain conditionallyThis guy's example helped me a bit agohttp://nicknot... |
in nginx config, what is the meaning of caret ^ by itself? | A bit down onthisnginx config reference page you'll see:rewrite ^ http://example.com$request_uri? permanent;What is the meaning of^above? | For rewrite, the first argument is the match pattern and only applies to the path portion of the url, not the domain. In regular expressions,^matches the beginning of the input. For example,^/photos/.*$would match paths beginning in '/photos/'. By itself,^is a shortcut for all paths (since they all have a beginning). |
How can i proxy to SSL backend without specifiyng cert files? | I have an Play 2.1.x application which signs itself using JKS. It's up, running and available atdomain.com:9443, I need to proxy it withnginx, as there will be more apps on the same machine, (therefore can't run it just on port443) I added the nginx config in hope thatproxy_passwithhttpswill allow me to just proxy it t... | The only option for proxy is to have the certificate inside nginx. Another option would be to just TCP forward the connection outside of ngnix, but then you will not get any of the X-Real-IP, X-Forwarded-For etc stuff. |
Nginx Cannot Find OpenSSL Development Headers | When I run:rvmsudo passenger-install-nginx-moduleon my Mac to install nginx, the terminal prints:Checking for OpenSSL development headers...
Found: noBut I am certain I have openssl installed.which opensslreturns/usr/local/openssl/bin/openssland/usr/local/openssl/bin:is the first entry in my $PATH. My questions are:A... | Ifbrew link openssl --forcegives you this message:Warning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's openssl. Instead, pass the full include/library paths to your compiler e.g.:-I/usr/local/opt/... |
Nginx rewrite in subfolder (404) | I has a site host on aNGINXserver which used to work fine to removeindex.phpin nginx site config usingtry_files.But now I am going to add a blog on it, where the URL will bewww.foo.com/blog, I can access the blog and useindex.php?p=.But, once I useprettypermalink with Nginx Helper,www.foo.com/blog/2013/07/bar, I get404... | The accepted answer routes everything throughindex.php.This will break certain script includes, thewp-adminscript being one of them.You can use:location /blog/ {
index index.php;
try_files $uri $uri/ /blog/index.php?$args;
} |
NGinX cannot connect to Jenkins on CentOS 7 | I have installed Jenkins CI on Cent OS 7 machine as well as NGinX and configured reverse proxy as outlined in thedocument. I can connect to Jenkins via port 8080, but cannot via port 80. I see the following error in/var/log/nginx/error.log:2014/09/22 22:12:35 [crit] 1639#0: *4 connect() to 127.0.0.1:8080 failed (13: P... | It seemed to be a SELinux related problem. As suggestedin this questionI have tried usingsetsebool -P httpd_can_network_connect 1and everything works fine after that. |
NGINX proxy_pass remove path prefix & resolve DNS | I'd like to proxy a request to another server using proxy_pass while removing the matched path prefix. I believe that one way of doing this is as follows;location /a/ {
proxy_pass https://website.com/
}E.g. a request tohttp://localhost/a/b.htmlwould be proxied tohttps://website.com/b.html.As far as I am aware the iss... | I'm not sure where you've seen it, but just using specifically$request_uriis certainly not going to magically make nginx resolve the domain names for you dynamically.Perhaps what was suggested was explicitly using the variables, such as$uri(which is a different variable), on the assumption that when the variables are i... |
Can Django run on Gunicorn alone (no Apache or nginx)? | I have tried just about every django + nginx tutorial on the web and I cannot get an image file to display on the screen. It's always the old story -404 PAGE NOT FOUND. The web page loads fine but django.png in my/static/folder does not. Not sure if it's a problem in settings.py or with nginx.I am so frustrated with it... | Yes. Gunicorn can serve your static too.If all else fails, let django do it for you (although, do this as a last resort before frustration.) To do that, you just have to add another url pattern, as follows:urlpatterns = patterns('',
# ... the rest of your URLconf goes here ...
) + static(settings.MEDIA_URL, documen... |
nginx logging $request_body as hexadecimal | I am trying to log the request body of requests to my api and nginx is turning all quotes (and some other characters like spaces and tabs) into hexadecimal characters.Here is my log formatlog_format postdata '{"ts": "$time_iso8601", "status": $status, "req": "$uri", "meth": "$request_method", "body": "$request_body"}';... | Sinse 1.13 there is an "escape=none" parameter that turns off data escaping.http://nginx.org/en/docs/http/ngx_http_log_module.html#log_formatlog_format api_request_log escape=none '[$time_local] $request \n$request_body'; |
What is the difference between an Ingress and a reverse proxy? | Currently, I am studying Kubernetes and I came across the term Ingress object. I was wondering if there is a list of differences between the two as to me they seem like synonyms. To me it seems that an NGINX is a more functional ingress as it allows for instance video and image compression, pre-fetching and caching.On ... | You are right in your understanding. Ingress has two parts a controller which implements Kubernetes ingress API interface for an automated and fast way to configure a reverse proxy such as Nginx or envoy.The other part is the reverse proxy itself such as Nginx, envoy.So when you deploy an ingress setup in Kubernetes it... |
get ip user with nginx and node | I have a problem with nginx and node, because when i want get the ip of user with node, in my localhost works ok(no use nginx) but in my server dont work as it should. I was researching and see that the node no is the first that receive the ip, is nginx and after nginx send the request to node. then the ip that node re... | You can configure NGINX to pass the client's IP address with the following setting:location / {
proxy_pass https://fotogena.co:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_s... |
nginx - redirect a certain path to another domain | I am very unfamiliar with nginx, as a forewarning, and also can't find any actual references on the regex system they use. So right now it's a black box to me.All I want to do is redirect a user trying to go to www.mydomain.com/mydirectory/X to www.myotherdomain.com/X .Seems like I should be using the rewrite command b... | I made a solution that works. I had it before posting this question but didn't realize I needed to restart nginx. Put the following inside your server block.rewrite ^(/mydirectory/)(.*)$ http://www.myotherdomain.com/$2 permanent; |
run ASP.NET Core app under Linux on startup | I would like to run my ASP.NET Core solution under linux with the result it runs on startup.From Microsoftdocs, there are 2 ways:ApacheandNginx.Both approaches involveproxy pass, e.g.Apache:
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
....Nginx:serve... | This sectionin docs describes, how to create a service file to automatically start your Asp.Net Core app.Create the service definition file:sudo nano /etc/systemd/system/kestrel-hellomvc.serviceThe following is an example service file for the app:[Unit]
Description=Example .NET Web API App running on Ubuntu
[Service]
... |
NGINX Error: upstream sent invalid chunked response while reading upstream | We have tomcat with Jersey serving APIs behind NGINX.
A new streaming API we have developed worked great when we call Tomcat directly, but started getting no response when calling it through NGINX.Looking at NGINX logs we got:upstream sent invalid chunked response while reading upstream | We have solved the issue by adding the following to NGINX:proxy_http_version 1.1I guess NGINX proxies traffic by default with http version 1.0, but chunked transfer encoding is a http 1.1 feature.https://forum.nginx.org/read.php?2,247883,247906#msg-247906 |
An unhandled lowlevel error occurred. The application logs may have details | I'm tyring to deploy a rails app to a digital ocean droplet and all seems to be configured ok but I get this error:An unhandled lowlevel error occurred. The application logs may have details.I'm not sure what to do as the logs are empty.Here's the nginx config:upstream puma {
server unix:///home/yourcv.rocks/shared/t... | This is because you haven't set your secret key correctly. Double check your config/secrets.yml file: It should be something like this:production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>Then in your droplet, you can runbundle exec rake secretto get your secret key. There are options likedotenvwhich is a useful... |
WebSocket connection failed with nginx, nodejs and socket.io | I try to setup nodejs with nginx. But when the client try to connect it fails with...WebSocket connection to 'ws://www.mydomain.com/socket.io/1/websocket/KUv5G...' failed: Error during WebSocket handshake: 'Connection' header value is not 'Upgrade': keep-alive socket.io.js:2371So how to enable websocket comunication?my... | first,upgrade your nginx server to 1.3 or higher.second,my nginx conf works.you can follow my conf.server {
listen 80;
server_name jn.whattoc.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host... |
"Cannot GET" on reverse proxy from Nginx to socket.io on express.js | I've followedthis tutorialto get Node.js working through Nginx on a two Ubuntu 14.04 servers via private networking (Node.js is on myappserver - accessible via private IP myprivatewebserver and publicly via mypublicappserver - and Nginx on mywebserver). Everything works fine til this point - I can access a node.js app... | This is because SocketIO uses/socket.iopath by default, so you need to configure Nginx so that it will proxy not only/noderequest, but/socket.iotoo:location ~ ^/(node|socket\.io) {
#your proxy directives
}(By the way, it looks like you have typos: you wroteproxypass, but the correct form isproxy_pass. The same goes... |
How to add headers in nginx only sometimes | I have a nginx proxy to a API server. The API sometimes sets the cache control header. If the API hasnt set the cache control I want nginx to override it.How do I do that?I think I want to do something like this, but it doesnt work.location /api {
if ($sent_http_cache_control !~* "max-age=90") {
add_header Cache-... | You cannot useifhere, becauseif, being a part of the rewrite module, is evaluated at a very early stage of the request processing, way beforeproxy_passis called and the header is returned from the upstream server.One way to solve your problem is to usemapdirective. Variables defined withmapare evaluated only when they ... |
How to remove a subdirectory from the url before passing to a script? | This has been asked onSO beforebut the answers have not been generalized. So here goes.I have two different web apps. They were made to be on different servers at the root. But now they are going to be placed into subdirectories on the same server. The script below is sending the subdirectory along with the URI's to... | You need to rewrite the uri without triggering a redirection as noted by usingbreak.Depending on the details of your set up, whether everything should go to the backend or whether Nginx should serve some requests such as static files, you will need either ...location /store {
try_files $uri @store_site;
}
location... |
How to serve a directory of static files at a certain location path with nginx? | I have files at/Users/me/myprojectand I want to serve them athttp://stuff.dev/somethingusing a simple nginx config. In the/Users/me/myprojectfolder is something like:index.html
scripts/
app.js
styles/
style.cssSo I really want to be able to accesshttp://stuff.dev/something,http://stuff.dev/something/scripts/app... | I tried this out on my VPS, and using thealiascommand worked for me:server {
listen 80;
server_name something.nateeagle.com;
location /something {
alias /home/neagle/something;
index index.html index.htm;
}
} |
TCP proxy to postgres database as an upstream server in nginx | Question: Is it possible to set Nginx as a reverse proxy for a database?
These are the flags I have at the moment and I believed that having the--with-streammodule was sufficient to use TCP streams to the database. Is this a PLUS feature?Nginx configuration options:--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modu... | The issue was the "http://database_server"
it is a tcp stream so you need to just proxy_pass database_serveralso keep alive is not a directive that goes in a tcp upstream server |
How to specify mimetype of files with no extension in NGINX config? | I have a server with nginx. And I have a lot of images - pngs and jpgs saved as files with no extension (like "123123123_321312").When I use tag "img" in html page, I get theese messages in console:Resource interpreted as Image but transferred with MIME type application/octet-stream: "http://xxxx/images/1350808948_9976... | You should use thedefault_typedirective :server {
...
default_type text/html;
location /images/png {
default_type image/png;
}
location /images/jpg {
default_type image/jpeg;
}
} |
Django + uWSGI + Nginx + SSL - request for working configuration (emphasis on SSL) | Does anyone have a working configuration for these four?- Django
- uWSGI
- Nginx
- SSLThe main question is how to correctly set upSSLfor this? I've googled a lot, and still can't get it to work. I have a working set up forhttpwithunix sockets, but that's as far as I could get.There are some other answers posted, but ... | server {
listen 80;
server_name example.com;
rewrite ^/(.*) https://example.com/$1 permanent;
}
server {
listen 443 ssl;
server_name example.com;
access_log /var/log/nginx/example.com_access.log combined;
error_log /var/log/nginx/example.com_error.log e... |
How to control NGINX 'Location' directive matching order? | I'm trying to optimize my 'location' directives and cannot find a good way of determining if a specific location match is even attempted. Usingechoinside the location block doesn't help here.The NGINX ngx_http_core_module documentationis somewhat confusing.To use regular expressions, you must use a prefix:~For case sen... | From the wiki:location = / {
# matches the query / only.
[ configuration A ]
}
location / {
# matches any query, since all queries begin with /, but regular
# expressions and any longer conventional blocks will be
# matched first.
[ configuration B ]
}So, this will be matched first:location ~ \.php$ {}E... |
PM2 deleted process runs on startup | I have a pm2 process namedappthat was used to test the configuration.I noticedappwas starting when the system rebooted, and it was causing errors with the real application.I ran:pm2 delete appthen I ran:pm2 listand it didn't showapp.When I reboot my system, the app is still there and it is running. I attempted to find ... | If you use "pm2 delete {appname}" to delete the last apppm2 delete appwhen you runpm2 saveIt will show[PM2] Saving current process list...
[PM2] Nothing to save !!!
[PM2] In this case we keep old dump file. To clear dump file you can delete it manually !Which means, actually, the last app information is still not delet... |
Jenkins and GitHub webhook: HTTP 403 | I have a GitHub repository which I would like to have notify Jenkins of new commits via a post-receive hook. I've installed the GitHub plugin into Jenkins and have allowed for Jenkins to manage it's own hook URLs. The project has the correct git repository URL and is instructed to "Build when a change is pushed to GitH... | As I don't allow anonymous access, it turns out I needed to create a specific user for GitHub pushes and to grant it Overall read, Job create and Job read. It was also necessary to bundle the authentication into the webhook URL, like so:https://foo:[email protected]/github-webhook/ |
X-Frame-Options header is not a recognized directive | I am using Nextcloud (on Nginx) for a while now and I want to iframe it for another website. However the header does not accept my directives.I changed the header option in /var/www/nextcloud/lib/private/legacy/response.php into the following:header('X-Frame-Options: ALLOW-FROM https://example.com');However when I make... | To come back to this post. Unfortunatly I found the problem. Chrome does not support this option, therefore Chrome gives me the error that the iframe redirected me to many times.However the option works on Firefox (More information here:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options). |
keep the nginx logs of the last 30 days [closed] | Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.This question does not appear to be abouta specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic onanother Stack Exchange site, ... | To change this behavior, you'll have to change the logrotate file of nginx.
This file is probably located in /etc/logrotate.d.
For achieving what you're trying to do, put the directivesweeklyandrotate 30inside the file corresponding to nginx.
After that, use the following command to ensure the changes take effect:logro... |
Add secure flag to JSESSIONID cookie in spring automatically | I have a tomcat application server that is behind a nginx.
SSL terminates on the nginx.
The Spring web-mvc application that is deployed on the tomcat should set the secure flag on the JSESSIONID.
It would be cool if spring has some automatic detection for this so I don't get bothered during development because I don't ... | When you usespring-session, e.g. to persist your session in reddis,
this is indeed done automatically. The cookie is than created byorg.springframework.session.web.http.CookieHttpSessionStrategywhich inCookieHttpSessionStrategy#createSessionCookiechecks if the request comes via HTTPS and sets secure accordingly:session... |
Nginx: Is it possible to get response retuned from auth_request | I am using auth module for nginx. (http://nginx.org/en/docs/http/ngx_http_auth_request_module.html)
Is it possible somehow to store the response from the /auth, so I can send it as a request body to another endpoint.location /private/ {
auth_request /auth;
proxy_pass ...
proxy_set_body 'Here I want to put ... | Short answer:No, you can't.Long answer:You can't get body of a response returned toauth_request. You can get a header returned in the response though, using theauth_request_setdirective:location / {
auth_request /auth;
auth_request_set $auth_foo $upstream_http_foo;
proxy_pass ...
proxy_set_body $auth_fo... |
ERROR: Invalid HTTP_HOST header: '/webapps/../gunicorn.sock' | After I deployed my Django App last night I got tons of strange Emails saying:ERROR: Invalid HTTP_HOST header: '/webapps/example_com/run/gunicorn.sockI'm sure this is somehow related to the following nginx config:upstream example_app_server {
server unix:/webapps/example_com/run/gunicorn.sock fail_timeout=0;
}
serve... | I found the answer to my my question in a django bug report.proxy_set_header Host $http_host;has to be replaced with:proxy_set_header Host $host;to make nginx pass the correct headers from that on instead of the gunicorn socket the requested page was in the django alerts. |
NGINX proxy_pass same protocol (http/https) | I have a section in my NGINX config file that usesproxy_passto redirect API traffic to upstream servers. I have thelocations in oneserverblock that serves both http and https requests:server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name mysite.local; # Valid TLD in... | You could use the$schemevariable:location /api/v1/json {
# Various proxy config directives
proxy_pass $scheme://your-host
}From thedocs:$scheme
request scheme, "http" or "https"Which would then use the same protocol as the original request. |
Nginx URL masking to a different domain | There's a few similar questions on SO, but none exactly mine, and I've had no luck trying to adapt their answers so far.I want to map the URLhttp://sub.example.comtohttps://123.12.12.12/path, such that the browser still shows the URLhttp://sub.example.com.My Nginx config file looks like,server {
listen 80;
serv... | server {
listen 80;
server_name sub.example.com;
location / {
proxy_pass https://123.12.12.12/path;
}
}Thats how it works. If proxy_pass contains locations part - current location will be replaced to specified.http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_passBut it's help only... |
Flask redirect(url_for) error with gunricorn + nginx | I am having a problem with the redirect(url_for) function in my flask app.Any redirect(url_for("index")) line redirects the application fromdomain.com/apptoip-addr/app, where theip-addris my own client machines ip, not the server's.This has gotten me very confused, and I don't know where exactly the issue occurs, as it... | Addinginclude proxy_paramsfixed it for me.location / {
proxy_pass http://...;
include proxy_params;
} |
Why does android get the wrong ssl certificate? (two domains, one server) | I have two domains:foo.netandbar.com. They both have SSL certificates, and they work well in all desktop and mobile browsers. They are hosted on the same server configured with nginx.However, when I make a request to a domain from within a native android app, it somehow gets the certificate from the wrong domain! This ... | The most likely cause for this problem is that the server usesServer Name Indicationto choose which certificate to send. If the client doesn't support SNI, the server cannot choose which certificate to send during the SSL/TLS handshake (before any HTTP traffic is sent). SNI is required when you want to use multiple cer... |
Reloading nginx & php5-fpm does not update changes to php.ini | I've made changes tomax_upload_sizein/etc/php5/fpm/php.iniand restarted both nginx and php5-fpm services.phpinfo()states that/etc/php5/fpm/php.iniis being loaded but after reloading/restartinb both services,max_upload_sizeremains unchanged.Question:A server reboot solved the problem. Why is a reboot required? Did I mis... | The issue is probably that you never actually restarted php-fpm. I had issues with this as well, apparently theres a bunch of different ways to restart php-fpm, and some of them dont work for certain environments.https://serverfault.com/questions/189940/how-do-you-restart-php-fpm/506951Try those and see if they reload ... |
nginx config for express app running on port 3000 | I'm trying to setup nginx so that it pull the app running on port 3000.When I visit mydomain.com:3000, the app works. I want it to run without the port.I have nginx setup and it's working properly.
I have an SSL cert setup and it's working properly (I'm able to see the nginx start page with SSL)
I have the www redirect... | I figured it out, since I was using SSL, I needed to make sure it was https. Here is my final config:upstream app_nodejs {
server 127.0.0.1:3000;
}
server {
#listen 80 is default
server_name www.mydomain.com;
return 301 $scheme://mydomain.com$request_uri;
}
server {
listen 80;
listen [::]:80;
... |
How to redirect address.com/foo/bar to address.com:port/bar with nginx? | I have running nginx on my server ansel.ms and a node.js app on ansel.ms:46156.I want to setup nginx so it redirects everything fromansel.ms/rhythmtoansel.ms:46156.
ansel.ms/rhythm/sub/pathshould becomeansel.ms:46156/sub/pathThis is my file in sites-available:upstream rhythm {
server ansel.ms:46156;
}
server {
... | I cannot spot the error in your configuration file; I'm an nginx-newbie as well.But here is my full nginx.conf config file which redirectshttp://myhost/cabaret/foo/bartohttp://myhost:8085/foo/bar:user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker... |
HTTP 444 (No Response) instead of 404, 403 error pages? [closed] | Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.This question does not appear to be abouta specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic onanother Stack Exchange site, ... | Redirect request then you can return status code easily:server {
error_page 500 502 503 504 @blackhole;
location @blackhole {
return 444;
}
} |
Nginx proxy_no_cache and proxy_cache_bypass | Here's the documentation:proxy_cache_bypassDefines conditions under which the response will not be taken from a cache. If at least one value of the string parameters is not empty and is not equal to “0” then the response will not be taken from the cache:proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment;proxy_... | Yes.If you just haveproxy_cache_bypassset true on pages you don't want cached (eg. logged in users) then they will still be saved into the cache and served to people who should get cached pages (eg. non logged in users).But setting bothproxy_cache_bypassandproxy_no_cacheto true means that those users neither receive no... |
How to check if nginx uses LuaJit and not Lua? | I installedhttp-lua-modulewith nginx, made a script that works perfectly fine, but now I want to be sure thatnginxusesLuaJitinstead ofLua(because my research shows that LuaJit is faster).I added to the.bushrcthose lines of code :export LD_LIBRARY_PATH=/usr/local/luajit/lib:$LD_LIBRARY_PATH
export LUAJIT_LIB=/usr/local/... | Edit yournginx.conffile, add alocationinto yourserver {}block:location = /lua {
default_type text/plain;
content_by_lua '
if jit then
ngx.say(jit.version)
else
ngx.say("Not LuaJIT!")
end
';
}Then start your nginx server and then access /lua in curl or in your ... |
nginx: Is it possible to capture response headers in access log when using nginx as a reverse proxy? | We are using nginx as a reverse proxy to control and log access to a Clojure (Java) web service application.We are able to generate anaccess_logand capture incoming headers using nginx just fine. Our Clojure app logs activity via log4j. Trouble is, is that we can't match an entry in theaccess_logto an entry generated b... | $http_x_uuid is header sent by client.
Response header send by upstream is $upstream_http_x_uuidhttp://wiki.nginx.org/HttpUpstreamModule#.24upstream_http_.24HEADER |
gunicorn.socket: Failed with result 'service-start-limit-hit' | I was deploying a django app and it failed because for some reason the gunicorn.socket file was not created even though before adding nginx it worked perfectly fine so I searched the internet and found thisanswerwhere the guy says that the reason for this is the virtual environment but I'm sure there must be a way arou... | I don't know django, but I am going to assume that this issue is similar to an issue I saw trying to get the MySQL service to start on one of my servers today (see here:https://stackoverflow.com/a/55141733/708323)Basically, the "start-limit-hit" message is a red herring - service start tries to start which ever service... |
Nginx Configuration Versioning Strategy | currently a project my team inherited has a complete mess on the nginx configuration across 10+ environments, we would like to implement a versioning strategy however im not sure how people "normally" achieve this. you make the whole nginx conf folder a git repo and ignore what you do not want to version? or have a sep... | We manage it via separate Git repository exclusive only for nginx configuration. Yes, it includes everything inside/etc/nginx/directory.But it's not synced directly on server, instead a bash script is used to pull changes, update configuration, and reload nginx configuration.Script example:# Pull changes
git pull
# Sy... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.