Prompt
stringlengths
14
160
Instruction
stringlengths
18
2k
Response
stringlengths
8
2k
get complete url using nginx and lua with openresty
If request URL istest.com/gifts.If i am usingngx.var.urioutput is/gifts/expected output istest.com/giftsCode :location /gifts { try_files $uri @url_change; } location @url_change { default_type text/html; content_by_lua ' ...
I don't really understand what you want, but if you want the actual full URL i think you can use this$http_host$request_uri;
django rest framework gives 403 when behind nginx but not directly
Using django-rest-framework. I'm getting HTTP 403 errors when running in production behind nginx. When I call a particular view, which inherits from APIView to support a GET operation, I get:{"detail": "Invalid username/password"}But... I only get this in a browser. I don't get it when I use curl for the very same U...
You will get 403 FORBIDDEN if you have throttling enabled. Based on this issue:https://github.com/tomchristie/django-rest-framework/issues/667, turning off the lazy evaluation of request.user/request.auth is probably the best thing to do.
Redirect URL to PHP only if file does not exist with Nginx
I am trying to get Nginx to rewrite URL space ./data/(.+).png to serveImage.php?guid=$1server { server_name my.server; listen 80; listen 127.0.0.1:80; root /var/www/my.server; index index.html; location / { try_files $uri $uri/ index.html; rewrite ^/data/(.+).png serveImage.php?...
Rewriting did not seem to work as planned (nothing that appeared to access.log or error.log gave even a hint that the rule was even caught). I made a more generic router that might fit better the other yet unknown needs as well.location / { try_files $uri $uri/ @router; index index.html index.php; error_pag...
ASP.Net MVC 2 on nginx/mono 2.8
I am trying to setup ASP.Net MVC 2 application on Linux environment. I've installed Ubuntu 10.10 on VirtualBox, then installed Mono 2.8 from sources. After that I have installed nginx and configure it as recommendedhere. Unfortunately, FastCGI shows me standard error 500 page:No Application Found Unable to find a matc...
Does your application work with xsp (xsp4 if you are using .net 4.0)? You'll want to make sure that is working before you try configuring the connection to another web server.Does nginx know where to find mono? You most likely have a parallel install and it won't be in the default paths.I use apache, but you may still ...
AWS log Insigts parse NGINX log
I am trying to use aws log insights to run query on my log group that contains nginx log.This is my log format that I have setup on my ec2 machine:log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';Sample NGINX...
You're 99% of the way there. All that is missing is matching the number of selectors and output variables, so if you would appenduser_agentto your list it would start to work.Sample working query:fields @message | parse @message '* - - [*] "* * *" * * "-" "*"' as remote_addr, timestamp, request_type, location, protocol...
Beanstalk deployment ignores my nginx configuration files in .ebextensions
I host my Java webapp on a single-instance Elastic Beanstalk environment and I added several ebextension files which successfully create config files for me upon each deployment. I can't however find a way of getting Beanstalk to add new configs within the/etc/nginxor/etc/nginx/conf.ddirectories.I followed the steps de...
I have just solved the same problem.you can easily solve the problem by configuring the following directory structure.~/my-app/ |-- readme.md |-- .ebextensions/ | |-- options.config # Option settings | -- cloudwatch.config # Other .ebextensions sections, for example -- .platform/ -- nginx/ ...
php-cgi.exe quits after exactly 500 hits
For the life of me, I can't figure this out.This is my development machine setup:Windows 7 Home Premium 64 bit,Webserver: NGINX 1.3.6 c:\users\user_name\devel\nginxPHP: 5.4.7 c:\users\user_name\devel\nginx\php5Everything works fine except that after exactly 500 hits, my php-cgi.exe quits unexpectedly. No error logs, n...
I finally figured it out. Maybe it was simple enough that I couldn't find the solution.Adding:SET PHP_FCGI_MAX_REQUESTS=0to the command file that launches the php-cgi.exe fixed it. I guess it defaults (when not set) to 500 hits before FCGI is killed.Obviously, there are good reasons for this and as GargantuChet has s...
nginx as a reverse proxy to limit http verb access
So I've got an app that uses CouchDB as the backend. Couch doesn't really have it's security/user model in place yet, and by default anyone can do anything (including deleting records and even the entire database). But, if we limit access to only GET requests we're much safer.I was hoping I could put nginx out front as...
You can get access to the HTTP request type from the$request_methodvariable. So:location / { if ($request_method = 'GET') { proxy_pass couchdb_backend; } }
Android - OKHttp: how to enable gzip for POST
In our Android App, I'm sending pretty large files to our (NGINX) server so I was hoping to use gzip for my RetrofitPOSTmessage.There are many documentations about OkHttp using gzip transparently or changing the headers in order to accept gzip (i.e. in aGETmessage).But how can I enable this feature forsending gzip http...
According to the followingrecipe: The correct flow for gzip would be something like this:OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(new GzipRequestInterceptor()) .build(); /** This interceptor compresses the HTTP request body. Many webservers can't handle this! */ static class Gzip...
Nginx block from referrer
I need block all http connections, who have referrer click2dad.net. I write in mysite.conf:location / { valid_referers ~.*http://click2dad\.net.*; if ($invalid_referer = ''){ return 403; } try_files $uri $uri/ /index.php?$args; }But i st...
It should be noted that an expression will be matched against the text starting after the “http://” or “https://”http://nginx.org/en/docs/http/ngx_http_referer_module.htmlCorrect config:location / { valid_referers click2dad.net*; if ($invalid_referer = ''){ return 403; ...
Nginx offers to download SVG instead of showing it
I try to show SVG file in HTML or separate tab but Nginx offers me to download it. I took normal SVG file which works on another site but not in my server.Where is a problem?Here is an examplehttp://proximax.ru/media/content/final/plane2.svgAlso here SVG in HTMLhttp://proximax.ru/index/
Theof your image is noted asapplication/octet-streamwhich a browser can only offer to download as it does not know how to interpret it.From yourindex.htmlfile it is clear that you were playing around with variations of the MIME-type, and it is unclear whether the standard requiresimage/svgorimage/svg+xml(or standards b...
Use Robo 3T to connect to remote MongoDB
I'm trying to use Robomongo (or Robo 3T) under Mac to control my mongodb in the remote Ubuntu & Nginx server.Normally, I need tossh xxx.xx.xx.xxin a terminal with a username and a password to connect to the server. in/etc/nginx/sites-enabled/myweb.io, there islisten 443 ssl.In Robo 3T, I tried to set up the connection ...
The correct setting is1) underSSH, checkUser SSH tunnel, use port222) and underConnection, write127.0.0.1:27017
Why does Nginx keep redirecting me to localhost?
Using Django on the backend with Gunicorn, each time I submit a form and am supposed to be sent toexample.com/pagetwoI am sent tolocalhost/pagetwoinstead.I'm new to Nginx so if someone could point out what the problem is I'd be most greatful :)default.conf:server { listen 80; server_name example.com; ...
In this situation, django is listening on some unix socket and all requests sent to django by nginx are local, so host that django sees is 'localhost'.Django must build full URL for any redirection when you're submitting form. Because only domain django knows about is 'localhost', django will build URL using that host....
nginx proxy - how to allow connection from a specific ip
I've installed nginx and set it up as a forward proxy (see attached nginx.conf) The server became overloaded and it seems like someone else was using it.is there a way to limit the nginx proxy to receive request only from specific ips?Please explain how I should change the nginx.conf to do it for ip 123.456.123.345work...
Do it like this:location / { allow 123.456.123.345; deny all; resolver 8.8.8.8; proxy_pass http://$http_host$uri$is_args$args; }From thedocs:The rules are checked in sequence until the first match is found.So if IP equals123.456.123.345, access will be allowed, otherwise - denied.If you want to allow m...
nginx custom error configuration referencing a string vs a file
I understand that I can set a file for a custom error page:location / { error_page 404 = /mybad.html; }But I'd just like to instead provide my page override as text inline in the config file:location / { error_page 404 = "Sorry!" }Is this possible with nginx?
location / { error_page 404 @sorry; } location @sorry { return 404 "Sorry!"; }http://nginx.org/r/error_pagehttp://nginx.org/r/return
How works gzip_types image/jpeg
I now and always use gzip with nginx but never use it for images. Try to find some adventages/disadventages of that kind solution but nothing found.Of course I can use client side caching in nginx and set expired days for images - but then first load will be always full load without any optimization.Soo should I or sho...
You don't compress images because images are already compressed. In some cases it can actually make them larger (but I've forgotten the reason why). These are binary formats, similar to videos and you won't gain any benefit.
how to do a linux reboot from php file
I have a user brftv on my linux system and I have www-data that runs the nginx.from the terminal I can let my brftv user runsudo /sbin/rebootand it works fine since I added the following to my /etc/sudoers file's "#user privilege specification" section:brftv ALL=NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff www-da...
The only way I got this to work on my system was to "hack" it by changing chmod on /sbin/reboot like this guy didhttp://linux.byexamples.com/archives/315/how-to-shutdown-and-reboot-without-sudo-password/sudo chmod u+s /sbin/rebootI realize this might not be optimal in many cases, but this mediaPlayer is very much locke...
restrict access to the admin url by ip in django with nginx and gunicorn
I am trying to restrict access to the admin section of my django app by using simple host-based access control in nginx. Unfortunately nginx does not seem to abide by the configuration request:this is my setting for this particular section in nginx:# gunicorn setup location / { proxy_pass http://127.0.0.1:8000; ...
I found a solution to this problem by replacing the /admin/ location with the following:location ^~ /admin/ { # restrict access to admin section proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded...
Location and document path in nginx
This is my nginx configuration file:server { listen 80; server_name localhost; location / { root d:/www; index index.html index.htm; } location /js/api/ { root D:/workspace/javascript/maplib/; autoindex on; } }And the directory of the document is like...
Usealias. Ref:http://nginx.org/en/docs/http/ngx_http_core_module.html#aliasThat is, replaceroot D:/workspace/javascript/maplib/;byalias D:/workspace/javascript/maplib/;
How to deploy Next.js static export with Nginx? (deep links not working)
I made a next.js export into theoutfolder.Folder structure is:outindex.htmlterms.htmlprivacy.htmlI set up nginx to serve files from this folder:server { root /var/www/myproject/out; index index.html index.htm index.nginx-debian.html; server_name myproject.com; location / { try_files $uri $uri/...
Issue is intry_files.As current configuration includes:/ (which default route to index.html at root path)index.html/index.htmltest/*.htmlTo access pages route path name without extension i.e.,/privacythat format should be included intry_filesinsdielocation /Try this:try_files $uri $uri.html /$uri /index.html
Where does `docker-compose logs` pull from?
Like most people who downvoted the sparseDocker docs page hereandhere, I'm confused by whatdocker-compose logsdoes.When I runcd /apps/laradock/ && docker-compose logs -f nginx, I see a very long output from many days ago til now.What file or files is that pulling from?The only nginx log file I could find was/apps/larad...
With the default logging driver,json-file, your logs are stored in/var/lib/docker/containers//. Do note that what gets logged here is the output of stdout and stderr from PID 1 of your container.As for "log rotate", the json-file driver has some options you can pass to it to limit the size per log file, and the maximum...
Docker - how do i restart nginx to apply custom config?
I am trying to configure a LEMP dev environment with docker and am having trouble withnginxbecause I can't seem to restartnginxonce it has it's new configuration.docker-compose.yml:version: '3' services: nginx: image: nginx ports: - '8080:80' volumes: - ./nginx/log:/var/log/nginx - ./ngi...
Basically you canreloadnginx configuration by invoking this command:docker exec nginx -s reload
Host Multiple Golang Sites on One IP and Serve Depending on Domain Request?
I'm running a VPS with Ubuntu installed. How can I use the same VPS (same IP) to serve multiple Golang websites without specifying the port (xxx.xxx.xxx.xxx:8084) in the url?For example,Golang app 1 is listening on port 8084andGolang app 2 is listening on port 8060. I want Golang app 1 to be served when someone request...
Please, try out the following code,server { ... server_name www.example1.com example1.com; ... location / { proxy_pass app_ip:8084; } ... } ... server { ... server_name www.example2.com example2.com; ... location / { proxy_pass app_ip:8060; } ... }app_ip is the ip of th...
nginx rewrite post data
I need to preserve the POST data to a different urlThe rewrite works but the post data is lostneed to post data from user_info.php to userhistorylocation ~ user_info.php { rewrite ^/.* http://testing.com/userhistory permanent; }The data is lost. How can I preserve the data?
Basically, you want to automatically redirect a POST request using a 301 Moved Permanently redirect.However. such redirect are specifically disallowed by theHTTP Specificationswhich states that:If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redi...
nginx group http auth
coming from apache2 the only feature i cannot archive: have users in a password-database (htpasswd) and allow the access to different files/folders/virtual servers.Basic http auth I enabled works:location ~ ^/a/ { # should allow access for user1, user2 auth_basic "Restricted"; auth_basic_user_fil...
I finally manage it like this with basic http auth:For each group I have a seperate password file, eggroup_a.auth,group_b.auth, ...In addition, I have a file where each user and password is written, egpasswords.txtpasswords.txthas the same format like auth files, so something likeuser1:password_hashI have a ruby script...
Nginx Bad Gateway
Hi I'm trying to move my old dev environment to a new machine. However I keep getting "bad gateway errors" from nginx. From nginx's errorlog:*19 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 127.0.0.1, server: ~(?[^.]+).gp2, request: "GET /favicon.ico HTTP/1.1", ...
Turned out that PHP-fpm was not running
User to start Passenger (with Nginx)
I have Nginx with Passenger. In nginx.conf I have line:user pass users;and Nginx process works on 'pass' user, but Passenger* processes work on 'nobody' user.I can run Passenger standalone:sudo passanger start -e production -p 80 --user=passHow can I run Passenger with Nginx with my custom user?
Put the following into yournginx.confin thehttpblock:passenger_default_user custom_username; passenger_default_group custom_group;You can find more configuration options here:http://modrails.com/documentation/Users%20guide%20Nginx.html#PassengerDefaultUser
How to get .crt and .key from cert.pem and key.pem
I know this is a super similar question to many other questions, but none of them either give a straight answer or one that works for me...I have gotten two files from Let's encrypt:cert.pemkey.pemI need to get them into acrtandkeyformat for use on an nginx server.I have tried:openssl rsa -outform der -in key.pem -out ...
The extension.pemindicates that the file format isPEM(Privacy-Enhanced Mail). However, the extension does not tell anything about the content of the file. The content may be a certificate, a private key, a public key, or something else.The extension.crtindicates that the content of the file is a certificate. However, t...
Nginx & Handling Files Without Extension
I'm trying to get Nginx to handle php files without an extension (i.e. to handlehttp://localhost/samplethe same way it would handlehttp://localhost/sample.php).This is my site configuration:server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name localhost; root /var/w...
try_files $uri $uri/ $uri.html @extensionless =404;Yes,@extensionlessis treated like a normal file, and that's because you've added an extra=404after@extensionlesswithintry_files-- the@extensionlesspart would only work as the last parameter as an internal redirect to another context.If you want not only to support hand...
Nginx sub_filter rewrites?
I am trying to rewrite body links of a proxied page using something like this:sub_filter http://proxied.page.come http://local.page.com; sub_filter_once off;Is this the way to go at all ? What is the difference between thesub_filter moduleand thesubstitutions_filterAlso can variable be used in the sub_filter delcar...
Ideally, you should ask backend to write correct links. While it is possible to fix some simple cases using sub filter, it is not something generally possible (e.g. if returned data isn't text but e.g. flash code).You can use variables in a replacement string in sub_filter (but not in string to match in original respo...
Using nginx map directive to dynamically set proxy upstream
I'm trying to make my Nginx a bit more dry, as it's acting as a reverse proxy for nearly 20 servers. Here's what I'm trying to do, all the hostnames and stuff are changed/examples:map $http_host $backend { baz.mydomain.com hostname1:8080; foo.mydomain.com 192.168.1.10:8081; bar.mydomain.com ...
I got it figured out. The issue was that it didn't like having hostnames in the list. The hostnames are needed as all these addresses are allocated dynamically. This was solved with the upstream directive as follows:upstream bazhost {server hostname1:8080;} upstream foohost {server 192.168.1.10:8081;} upstream barho...
May I use two named locations within try_files nginx directive?
I want to use something like:location @a1 { ... } location @a2 { ... } location /path { try_files @a1 $uri @a2 }Does it possible and what should I do at @a1 location to continue tries with $uri / @a2?If so, how nginx will process that?
I have foundthis solution:location /static/ { try_files $uri @static_svr1; } location @static_svr1{ proxy_pass http://192.168.1.11$uri; proxy_intercept_errors on; recursive_error_pages on; error_page 404 = @static_svr2; } location @static_svr2{ proxy_pass http://192.168.1.12$uri; proxy_inte...
Adminer login via a reverse proxy
I am running Nginx which is configured to allow me to access several resources on another server which is available as a reverse proxy. For examplemain server:http://example.com slave: http://example.com/slave adminer on slave: http://example.com/slave/admin/adminer.phpEverything is all right so far. I enter my DB us...
I hit the same problem and the most simple fix I could come up with is to patch the adminer PHP script. I simply hardcoded$_SERVER["REQUEST_URI"]at the start ofadminer.phplike this:--- adminer.php 2015-10-22 12:31:18.549068888 +0300 +++ adminer.php 2015-10-22 12:31:40.097069554 +0300 @@ -1,4 +1,5 @@ <?php +$_SERVER["R...
Nginx cannot restart via Ansible
I have a task in a playbook that tries to restart nginx via a handler as per usual:- name: run migrations command: bash -lc "some command" notify: restart nginxThe playbook however breaks on this error:NOTIFIED: [deploy | restart nginx] ******************************************** failed: [REDACTED] => {"failed": ...
The handler was:- name: restart nginx service: name=nginx state=restarted enabled=yesIt seems that the state and enabled flags cannot both be present. By trimming the above to the following, it worked.- name: restart nginx service: name=nginx state=restartedWhy this is, and why it started breaking suddenly, I do no...
After pulling a Docker from the repository, how to change the images files?
I installed a docker image from the registry by doing.docker pull paintedfox/nginx-php5Now I wish to make some changes to this nginx's config files to add some domains. I believe the config files are somehow help inside the dockers image, but where is the image? How can I change these config files?
You can run a shell in the image, with:docker run -t -i --entrypoint bash paintedfox/nginx-php5Then change the configuration files as you like. Note the container ID (it appears in the prompt, e.g.root@9ffa2bafe2bb:/#), then commit it to a new image:docker commit 9ffa2bafe2bb my-new-nginxYou can then run the new image ...
How to create mysite.wsgi file?
I am following this tutorialhttp://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.htmlto setup django with nginx and uwsgi. But I am confused about this line:uwsgi --http :8000 --module mysite.wsgiIn the tutorial there's nothing about mysite.wsgi file. What should be the content of this file?
Actually, that's not a filename.That's a python module path.The relevant file is actuallymysite/wsgi.py(but to import it in a python interpreter, you'd have toimport mysite.wsgi, hence the name used in command line).
Configure Nginx to be a TCP load balancer
I want to use Nginx 1.9 to be a TCP load balancer. I followed the tutorial inhttps://www.nginx.com/resources/admin-guide/tcp-load-balancing/but it didn't work.Every time I tried to start nginx, I've got errors:nginx: [emerg] unknown directive "stream" in /opt/nginx/nginx.confHere is my nginx.conf file:events { work...
The best way is compiling nginx from source to supportstreamdirective:./configure --prefix=/opt/nginx --sbin-path=/usr/sbin/nginx --conf-path=/opt/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --with-http_ssl_module --with-threads --with-stream --with-http_slice_module make sudo make i...
Changing Passenger Default Error Page for Nginx
Currently if there's a problem launching a Rails app on our server, users are taken to a Passenger error page with an error like "Ruby (Rack) application could not be started".Is it possible to customize this error page and display something else so users of a live site don't see this?I'm using nginx for the server.Tha...
In testing Passenger 5.1, I found that settingpassenger_friendly_error_pages offis not enough to change the default error page. This disables exposing backtrace or environment variables but still shows Passenger's error page.To resolve this I had to set the following:passenger_intercept_errors on; error_page 500 /500.h...
nginx not setting expires headers on Rails static assets
I can't seem to get nginx to set expires headers on my static assets in my Rails app.My app is deployed using Phusion Passenger & nginx.Below is the related section of my nginx config fileserver { listen 80; server_name my.domain.tld; root /home/deploy/my.domain.tld/current/public; pass...
So I ended up finding the solution. My regexp was a bit off, as I wasn't taking into account the possibility that the ?timestamp didn't exist.This regexp worked for me.location ~* \.(ico|css|js|gif|jp?g|png)(\?[0-9]+)?$ {
duplicate extension "woff", content type: "font/woff2", previous content type: "font/woff" in /etc/nginx/mime.types
After the latest Nginx update (currently nginx/1.21.6), the following warning started to appear when I do anginx -t:nginx: [warn] duplicate extension "woff", content type: "font/woff2", previous content type: "font/woff" in /etc/nginx/mime.types:29The same issue is happening on all my servers, with Ubuntu 18.04 or 20.0...
I found out where the issue was, If you have the same issue you're probably using theppa:ondrej/nginx-mainlinerepository, and you have:font/woff woff; font/woff2 woff;Instead of:font/woff woff; font/woff2 ...
Nginx running in WSL2 (Ubuntu 20.04) does not serve HTML page to Windows 10 host on another port than port 80
I am new to WSL2 but so far it works really nice. I have a simple HTML Page i want to serve with Nginx, but i want it to access with a web browser on the host. The default nginx webpage works(!), so i started to mimic the default nginx html page (/var/www/html/index.html).I have created:/var/www/test.dev/index.html/etc...
In your nginx config you have:listen 9000; server_name test.dev;So your domain should be resolved with:http://test.dev:9000But you should also addtest.devto your Windowshostsfile%windir%\system32\drivers\etc\hosts127.0.0.1 test.dev
How would you use Hashicorp's Nomad 'template stanza' to generate an nginx config file through the Nomad job file?
With the assumption that Consul and Nomad has been configured to run on a pool of resource. How would you rendered a template file for the sole purpose of generating e.g. an Nginx 'default.conf' file.Using the template stanza configuration below, as an example; Nomad fails to generate a default.conf 'file'; instead a d...
I just put together a little Nomad job showing this working, so you may have a slight configuration error. To allow you to run the job yourself I have made it available as agist here. In the same gist I have a nginx.conf that has nginx listen on whatever port is in the Nomad job file.Here is the Nomad job:job "nginx" {...
How to get Nginx to use alternative PHP version?
I have an Ubuntu web server running Nginx. I was runngin PHP 5.5.30 and I installed PHP 5.6.23 using the following commands:1) sudo apt-add-repository ppa:ondrej/php 2) sudo apt-get update 3) sudo apt-get install php5.6The installation is under a new path from the previous verison of PHP (/etc/php/5.6/). When I run a p...
I have the same problem. You forgot to change the default sockets fromfastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;tofastcgi_pass unix:/var/run/php/php5.6-fpm.sock;- you can find the configuration file at/etc/nginx/sites-available/default.Before:fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;After:fastcgi_pass unix...
nginx php-fpm failed to open stream permission denied
I have a php file on my NGINIX(with php-fpm) that create a simple txt file.But this works only when I give my "www" folder 777 Permission. My Index.php is placed in my www folder.What is wrong with my user settings on nginix and php-fpm?
After i give ownership of my www folder to my nginx user (as defined in/etc/nginx/nginx.conf), it works!chown -R www-data:www-data www
Nginx rewrite rule for CodeIgniter
Here is the rule in English:Any HTTP request other than those for index.php, assets folder, files folder and robots.txt is treated as a request for your index.php file.I have an.htaccessfile that works correctly on Apache server:RewriteCond $1 !^(index\.php|assets|files|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L]S...
You can add this to your config:location ~* ^/(assets|files|robots\.txt) { }This will work correctly with yourlocation /rule.Your config also need to add root document and default index file.... root /ftp/wardrobe; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?/$request_uri; } ...
NGINX configuration to work with Socket.IO
So I have been trying to get this to work 2 days and I am stuck. This is my first time configuring a server for rails that uses NodeJS+Socket IO. I am a noob with NGINX and Unicorn. Basically the NodeJS+SocketIO part of my app will push messages to users who are connected to my app. This is my nginx.confserver{ lis...
Updated AnswerI have finally figured out a way to get this working. It's not at all obvious, but when hosting socket.io on a subfolder, you do NOT use the subfolder in the connect statement. This is what I was doing before and the client was never receiving a response.Not Working http://localhost:8080/test/This is the ...
Can I echo a request header value as the response body with vanilla Nginx?
Is it possible to configure Nginx to return a response body created from a request header, or a request parameter? It looks like this can be done with theechomodule, but if possible I would like to do it with a vanilla install of Nginx.Basically I want to do the following, but obviouslyreturn_bodydoesn't exist, so what...
You can do this withreturn200:location = /echo_user_agent { return 200 $http_user_agent; }
nginx install on linux
I downloaded nginx from it's site for linux(I use ubuntu 10.4).I extracted nginx-1.0.6.tar.gz and there was a configure file in that directory. So I entered "./configure" command in shell. It seemed to be configured right.After I entered "make" command ,It said this error:make -f objs/Makefile make[1]: Entering directo...
you have to install Dependencies . generally these will be enoughlibpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-devso you can first install themsudo apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-devand then compile .. also make sure you run the make command as root.
Nginx reload error in mac osx
Greeting, i have a server installed nginx streaming i did stop nginx and then did reload it, but it show me below error and was not start:nginx -s stop nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)i did below command and nothing:sudo nginx nginx: [emerg] open() "/usr...
I fix it by removingnginx.pidin/usr/local/var/runand then usingbrew services start nginx
Why does ruby rails need puma or unicorn?
In php, you only need apache or nginx. Why does ruby rails also need something like puma or unicorn when nginx is already installed?
This is not entirely correct, to run PHP with apache you will need either the apachemod_phpor run it as aFastCGI module. For Nginx the latterseems to be the norm.For Ruby there'sPhusion Passengerthat fills this role, and supports both apache and nginx. On apache it runs as a plugin module just the way mod_php does. For...
Laravel Homestead vhost configuration
I am using Laravel homestead. For a project I need a special vhost configuration, where should I define this?
You add a new folder mapping into the "sites" block of Homestead.yml, like so:- map: myapp.com to: /home/vagrant/Code/myapp/publicThat's all there is to adding a new vhost. To modify it, edit the appropriate file in/etc/nginx/sites-available. In the above case, this would be/etc/nginx/sites-available/myapp.comSeehere...
Deny access to a PHP file (Nginx)
I want Nginx to deny access to a specific PHP file, let's call itdonotexposeme.php, but it doesn't seem to work, the PHP script is run as usual. Here is what I have in the config file:location / { root /var/www/public_html; index index.php; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_ind...
The order in which nginx determines which location matches can be found here:http://wiki.nginx.org/HttpCoreModule#locationUsing either of these will be matched before any other regular expression:location = /donotexposeme.phpOrlocation ^~ /donotexposeme\.phpThe first is an exact match whereas the latter is a regular ex...
Custom headers not received in nodejs while using nginx reverse proxy
I have nodejs and nginx running i am sending an additional header in the API 'api_key' and its not received inreq.headersandreq.get('api_key')in nodejs i have bellow configuration file for nginxserver { listen 80; listen [::]:80 default_server ipv6only=on; server_name mysite.com; return 301 https://$hos...
By default,nginxdoes not pass headers containing underscores.Try:underscores_in_headers on;Seethis documentfor details.Alternatively, useAPI-KEYorX-API-KEYinstead ofAPI_KEY.
Unicode domain name in Nginx server_name
I am trying to set up a server with a domain name called "privatinstruktør.dk" but keeps getting redirected to the default "welcome to nginx" page.I have tried to type in the server_name like this:server { listen 80; server_name privatinstruktør.dk; location / { root /var/www/privat; } }but that did not wo...
Configure a Unicode domain name usingpunycodeformat in nginx:server_name xn--privatinstruktr-jub.dk;
How to use Laravel Echo on production server with https
I'm wondering what's the proper (or any for that matter) way of setting up Laravel Echo on an https production server. I've had it working on my local vagrant for a little bit now, and now that I've pushed the changes to production I'm unable to get the script to connect to the node server. Here is what I currently h...
This is how I solved the problemFirst. You have to configure your nginx vhost with ssl (no websocket connected yet). I use Let's encrypt (https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04)Second. You could create a path on your vhost to proxy to your websocket. Thi...
nginx 500 Internal Server Error
When I access 127.0.0.1:6789 it works fine, but when i try to access something like 127.0.0.1:6789/busca.html?q=a, I got 500 Internal Server Errorthis is my nginx config fileserver { listen 88; root /vagrant/rizqcursosonline/rizqcursosonline/frontend/wwwpublic; index index.php index.html index.htm; ...
instead oftry_files $uri $uri/ /index.html;I usedtry_files $uri/ $uri /index.php?$query_string;
Nginx $request_time and $upstream_response_time in Windows
I'm encountering some weirdness in my access log running Nginx on Windows. I've included $request_time in my access log as well as $upstream_response_time (running Django as fcgi upstream). It's my understanding that the log should represent request time in milleseconds, but it's output looks like this:ip|date|reques...
So as you suggest here comes the answer:When you make request to your server (nginx+upstream) as GET then$request_timeresult with normal and acceptable value. That happens because your upstream server doesn't take part in it and even if it does it makes it properly.Problems start when you are doing POST request. Accord...
How to run nginx + python (without django)
I want to have simple program in python that can process different requests (POST, GET, MULTIPART-FORMDATA). I don't want to use a complete framework.I basically need to be able to get GET and POST params - probably (but not necessarily) in a way similar to PHP. To get some other SERVER variables like REQUEST_URI, QUER...
You should look into using Flask -- it's an extremely lightweight interface to a WSGI server (werkzeug) which also includes a templating library, should you ever want to use one. But you can totally ignore it if you'd like.
Multi Site WordPress rewrite rules in Nginx
I'm trying to run a multi domain blog installation with WordPress and Nginx. The last step is to configure some rewrite rules in.htaccess(apache only) for the webserver. How do I translate this into Nginx rewrite rules?RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^files/(...
nginx rewrite rules example for Wordpress 3:server{ server_name *.example.com; listen 80; #on server block ##necessary if using a multi-site plugin server_name_in_redirect off; ##necessary if running Nginx behind a reverse-proxy port_in_redirect off; access_log /var/log/nginx/example-c...
How to redirect http to https for a reactJs SPA behind AWS Elb?
I chose to use express server for deployment as pointed to indeploymentsection of create-react-app user guide. The express server is set up on an EC2 instance and is fronted by an AWS Elb, where the SSL terminates. How do I setup redirection of http requests to https?I am open to using Nginx as well, if there is a solu...
const express = require('express'); const path = require('path'); const util = require('util'); const app = express(); /** * Listener port for the application. * * @type {number} */ const port = 8080; /** * Identifies requests from clients that use http(unsecure) and * redirects them to the corresponding https(...
Nginx error 404 when using autoindex
I'm completely new to nginx. I've installed nginx on windows pc.What I want to do is server a list of files inD:\onlocalhost:8082/list.If I use the following conf:server { listen 8082; location / { root D:/; autoindex on; } }I can correctly see what i want onlocalhost:8082. But if I c...
What you need isaliasinstead ofroot.server { listen 8082; location /list { alias D:/; ##### use alias, not root autoindex on; } }SeeNginx -- static file serving confusion with root & alias
nginx proxy to remote node.js express app in subdirectory
I am completely stuck with a situation where I want to have several node applications on one server. I get this working fine by having the applications running on different ports. I can access the applications by putting in the ip address with port.I would like to proxy the applications from my nginx server by using di...
An updated answer for anyone who needs:instead oflocation /app1 { proxy_pass http://10.131.6.181:3001/app1; }uselocation /app1/ { proxy_pass http://10.131.6.181:3001/; }or if on locallocation /app1/ { proxy_pass http://localhost:3000/; }This is the correct way and this way you will not need to modify express. Exp...
nginx rewrite regex min,max repetition
I am using this rewrite in NGINX.rewrite ^/test[^a-zA-Z0-9]{2}/?$ https://www.google.com permanent; // doesn't workThe server fails to start with I add themin {2}repetition in the regex. The server comes up when I remove that like here:rewrite ^/test[^a-zA-Z0-9]/?$ https://www.google.com permanent; // this worksI have ...
This is by design -- curly brackets are special in nginx.conf, if used as a part of a regular expression, then you have to use double quotes around your regular expression if you're using the braces.http://nginx.org/r/rewriteIf a regular expression includes the “}” or “;” characters, the whole expressions should be enc...
How to set up two-way SSL in Nginx for custom location?
I have a rails 4 project with some API.This project runs withnginx v.1.6.3andhttpson production.Nginx configurations:upstream app { # Path to Unicorn SOCK file, as defined previously server unix:/tmp/unicorn.my_domain.sock fail_timeout=0; } server { listen 80; server_name my_domain.com...
Yes (see thessl_client_certificateandssl_verify_clientdirectives).Depends on your application, but in this case where you only need to verify that the certificate was signed by a certain CA, that's correct.You would need to create a CA and a client certificate signed by said CA and use that CA for verifying the client ...
SSH and -bash: fork: Cannot allocate memory VPS Ubuntu
I am hosting my Rails app on Ubuntu 12.04 VPS, Nginx + Unicorn, after deployment everything is fine, but few hours later, when I ssh to the VPS I get this message-bash: fork: Cannot allocate memory -bash: wait_for: No record of process 4201 -bash: wait_for: No record of process 4201If I run any command, it would jus...
Seems you have run out of memory. Many VPS servers are setup with no swap, so when you run out of memory, it will kill things off in a seemingly random manner.The easiest way to fix it is to get more memory provisioned to your VPS, likely costing more money. The next best way (other than running less stuff and memory...
Writing the total request time in seconds to an nginx access log, possibly using a calculated variable
I'm trying to modify my nginx access log format to include the request duration, in seconds.I see two possible variables I could use:1)$request_time2)$upstream_response_timeHowever both of these variables are expressed in microseconds, and I need this value to be rendered in seconds. Is there any way to specify the out...
The webserver is not a calculator or statistical program. It's logging function is to provide the raw data you can do your analysis with. If you analysis program is incapable of converting microseconds to seconds you should shop around for other software. In any case, it us unrealistic to expect a program's logging fun...
nginx proxy and 404 redirect
Hi I would like configure my nginx server to proxy for amazon S3 and do something like mod_rewrite in apache - if proxy for amazon is 404 (file does'nt exist on amazon) then redirect me to my local file. It's possibble to do ?This is my nginx config file:upstream app{ server 127.0.0.1:3000; } server { listen 0.0.0....
Addproxy_intercept_errors on;tolocation /photos. Then yourerror_page 404 /myerrorfile.jpgwill work even when the 404 error comes from the upstream server.
Connecting pgadmin to postgres in docker
I have adocker-composefile with services forpython,nginx,postgresandpgadmin:services: postgres: image: postgres:9.6 env_file: .env volumes: - postgres_data:/var/lib/postgresql/data ports: - "5431:5431" pgadmin: image: dpage/pgadmin4 links: - postgres depends_on: ...
Be careful that the default postgres port is 5432 not 5431. You should update the port mapping for the postgres service in your compose file. The wrong port might be the reason for the issues you reported. Change the port mapping and then try to connect to postgres:5432. localhost:5432 will not work.
Where does the W/ in an etag appear from?
I am confused by how the W/ appears in the etag when I have not added it. I am using Node.js http server module and have a Nginx as reverse proxy. I am getting the browser see the Etag generated by the Node.js server but with a W/ tagged to it.Can someone explain where that W/ comes from? Does the browser insert that ...
If you ask nginx to dynamically gzip your content it will convert your ETags into weak ones. This is required bythe specification, since a strong ETag can only be used for content that is byte-for-byte identical.A validator is weak if it is shared by two or more representations of a given resource at the same time, unl...
Is there a way to serve external URLs from nginx-kubernetes ingress?
Setup: Kubernetes cluster on AKS with nginx-kubernetes ingress. Azure Application Gateway routing domain with SSL certificate to nginx-kubernetes.No problems serving everything in Kubernetes.Now I moved static content to Azure Blob Storage. There's an option to use a custom domain, which works fine, but does not allow ...
Not exactly the answer to the question, but the answer to the problem. Unfortunately this isn't documented very well. The solution is to create a service with a type of "ExternalName". According tohttps://akomljen.com/kubernetes-tips-part-1/the service should look like this:kind: Service apiVersion: v1 metadata: name...
Nginx multiple locations with different roots
I have really simple nginx configuration with 3 locations inside. Each of them have it's own root directory + I should be able to add another in the future easily.What I want:Request/admin=> location^/admin(/|$)Request/admin/=> location^/admin(/|$)Request/admin/blabla=> location^/admin(/|$)Request/client=> location^/cl...
When you change the root it'll still include the directory name, so what you want to do is only set the root forlocation /. You also don't need any additional regex on/adminas the location modifier~already tells nginx 'anything starting with'.This works for your use case:server { listen 80; index index.html; ...
nginx configuration for multiple sites on same server
I am trying to create a nginx server that can host multiple sites on the same server. I have kept two different directories containing index.html files in the /var/www/ directory.1st directory : dir1 Containing folder strucuture as : dir1/Folder/app; app directory contains index.html for the site.2nd directory : dir2 C...
The above configuration should raise an error as you have defined twodefault_server, Also there is no point in defining two server blocks for the same domain,This is how you can achieve it,map $request_uri $rot { "~dir1" /var/www/dir1/Folder/app/; default /var/www/dir2/Folder/app/; } server { listen 80 defa...
Gunicorn stuck at Booting worker with pid: 9293
I am trying to implement nginx + django + gunicorn for my project deployment. I am taking the help of following article:http://tutos.readthedocs.io/en/latest/source/ndg.html. I followed the steps as described. Now, I am trying to start gunicorn. What am I getting at the screen is:$ gunicorn ourcase.wsgi:application [20...
That output means that the process is running. Which is what you want. You should try accessing the URL from the browser directly after running the command without pressingctrl+c.As a side note you can write a bash script to do this which will make it easier to add arguments to the gunicorn commands.I have a gist that ...
Basic Auth and JWT
I'm currently running a Node.js application, with an API and files serving (I know nginx could handle it, but I wasn't supposed to use it at first).I'm simply using it to have a simple basic auth, which happens to be not that simple.Here is my nginx config:upstream nodejsapp { server 127.0.0.1:1337; keepalive 1...
When I realised that the problem was theconflictbetween Basic Auth and JWT (as @Curious suggested in the commend), and that they are both using theAuthorizationheader, the solution was quite easy.I configure my front end application to send the JWToken via a custom header,**JWTAuthorization**, so when the request hits ...
Configuring Nginx reverse proxy for webmin
I already have a working https site running. My config below is working fine for webmin. Except that when I login the web address rewrites the port no 10000 next to it, therefore getting error server not found. can anyone help me to correct this please?server { server_name webmin.example.com; listen 4...
Replace theproxy_set_header Host $host;line withproxy_set_header Host $host:$server_port;to redirect the link without port number.server { server_name webmin.example.com; listen 443; ssl on; ssl_certificate /etc/webmin/miniserv.pem; ssl_certificate_key /etc/webmin/miniserv.pem; access_log off; error_log o...
How to configure nginx + Unicorn to avoid timeout errors?
I have a Rails (v3.2.13, Ruby 2.0.0) application running on nginx + Unicorn (Ubuntu 12.04). All is working well, except when an admin user is uploading users (thousands) via a CVS file. The problem is that I have set timeout to 30 seconds and the import process takes much more time. So, after 30 seconds I get an nginx ...
This is a good reason to create a queue. And you will:upload csv file (that should be within 30sec)your background job that will import user data (that can go for hours…)while this job is in progress you can serve some kind of WIP page with job status/percents/etc.Checkhttps://github.com/resque/resquefor example. There...
nginx subdomain configuration on virtual host
There are several questions on SO about nginx subdomain configuration but didn't find one that exactly the same as mine.Say I got a virtual hostsome.example.comfrom higher-level net adminexample.comat our organization. I want to usesome.example.comas my primary site and usefoo.some.example.comandbar.some.example.comfor...
Sub-domain configuration starts with an entry in the DNS server of the parent domain and the lookup resolves the sub-domain to an IP address of the web server. The web server in turn delegates the requests based on its configuration for the sub-domain.If you don't have a DNS setup in your sub-domain, then the admin at ...
uWSGI Server log…permission denied to read file...which file?
I have a server running Django/Nginx/uWSGI with uWSGI in emperor mode, and the error log for it (the vassal-level error log, not the emperor-level log) has a continual permissions error every time it spawns a new worker, like so:Tue Jun 26 19:34:55 2012 - Respawned uWSGI worker 2 (new pid: 9334)Error opening file for r...
The actual answer to this question appears to be this Ubuntu-specific bug:https://bugs.launchpad.net/ubuntu/+source/libjpeg-turbo/+bug/1031718You can work around the problem by putting the linessetuid uwsgiuser setgid uwsgiuserinto your upstart configuration file, and deleting theuidandgidsettings from your uwsgi confi...
nginx + FastCGI for django application---run two webservers or one?
I'm about to deploy a Django application on a nginx web server, and want to make sure I'm building the system correctly.It seems to be common wisdom that if you are deploying Django on an apache server, then you should still put an nginx server in front of the application to serve static files, at which nginx is more p...
Most config directives can live inside location blocks (i.e., they are not global-only) and it's very common to do this is practice. You should have no trouble setting this up using only 1 instance of nginx.One of the great things about this is that you can set it up this way initially and then change your mind later b...
default_type application/octet-stream in nginx.conf file
In the default nginx configuration file i see that the default_type is set to application/octet-stream. I understand the MIME types but I do not understand why we are setting a default type. What is the significance of this configuraion? Can someone help me to understand this?include /etc/nginx/mime.types; defaul...
Thedefault_typeonlyapplies to file extensions that have not been defined in themime.typesfile.If the file extension is missing from themime.typesfile, it's fairly safe to assumeapplication/octet-stream, which most browsers will treat as a binary file and download it rather than attempting to render it.Themime.typesfile...
Kubernetes Ingress: two microservices running on the same port?
I am building a microservice full stack web application as (so far) :ReactJS (client microservice) : listens on 3000Authentication (Auth microservice) : listens on 3000 // accidently assigned the same portTechnically, what I have heard/learned so far is that wecannot havetwo Pods running on thesame port. I am really co...
Each Pod has its own network namespace and its own IP address, though the Pod-specific IP addresses aren't reachable from outside the cluster and aren't really discoverable inside the cluster. Since each Pod has its own IP address, you can have as many Pods as you want all listening to the same port.Each Service also ...
Microservices, API Gateways, and Frontends [closed]
Closed. This question isopinion-based. It is not currently accepting answers.Want to improve this question?Update the question so it can be answered with facts and citations byediting this post.Closed3 years ago.Improve this questionI have recently begun exploring the concept of microservices and API gateways and am pa...
I assume your frontend is Single Page Application. SPA has static content like HTML, CSS, images, fonts etc. It is the perfect candidate to be deployed as static website that gets data from backend using REST APIs.In cloud environments like AWS, GCP it is recommended to host SPA applications separately from REST APIs. ...
What is the order of the config file for NGINX
I have the following config files and locations:etc/ngnix/nginix.conf var/etc/nginx/sites-available/myproject etc/ngnix/conf.d/default.conf etc/ngnix/conf.d/web.confI'm confused regarding each conf file role, rules, when to use one or another, are they loaded one after another, or just one, are directives overwriting ?
Thenginxconfiguration file is callednginx.confand on most systems is located atetc/nginx/nginx.conf.nginx.confmay optionally containincludestatements to read parts of the configuration from other files. Seethis documentfor more. Read yournginx.conffile to identify which files and directories are sourced and in which co...
Can I enable HTTP/2 for specific server blocks (virtual hosts) only, on Nginx?
I have several virtual hosts onnginx.Can I enableHTTP/2forspecific virtual hosts onlyonnginx?When I enableHTTP/2for a virtual host, like:server { listen 443 ssl http2; server_name a.b.com; ... }I can access a.b.com by HTTP2.0.But now every other virtual host on the samenginxsupports HTTP/2 too. But I wan...
Short answer: not possible on your current setup.When starting,nginxfirst creates a separate process for every group of virtual hosts that listen on the sameIP:portcombination, and then sets the capabilities of that process to be the sum of all capabilities of every virtual host in that group handled by said process.In...
Why does ActionDispatch::Request.original_url return the wrong scheme?
I have a Ruby on Rails app that has the following within a template...When I request the page over https I end up with a form action that has the exact same url as the original request, but instead ofhttps://it's being generated ashttp://, resulting in mixed content errors.What am I missing? Under what circumstances wo...
It looks like this might be the solution to the problem:http://blog.seancarpenter.net/2013/09/02/rails-ssl-route-generation-with-nginx-and-unicorn/Because the site is running within nginx, nginx is terminating SSL, and Rails has no idea that this is the case.To pass this info on to Rails, the nginx config needs to be s...
Using MAMP with NGINX
I see the latest versions of MAMP include NGINX 1.6.Can NGINX be used instead of apache, or is it just being used to server cached content. If possibel I'd rather use NGINX directives instead of .htaccess.
Looks like you can use NGINX as web-server instead of Apache.
Nginx redirect all contents of a subdirectory to another subdirectory
Let say that I have a url like this:http://www.example.com/admin/admin.php?fail=1how can I rewrite the url to behttp://www.example.com/another/subdirectory/admin.php?fail=1Thank youUpdate: this is what I've tried so far, but it will not redirect admin.php?fail=1location /admin/ { rewrite ^/admin/(.*)$ /another...
I rather use return 301 for redirections and use rewrite only if I want to display something like a nice url.Please try the followinglocation ~ ^/admin/(.*) { return 301 /another/subdirectory/$1 ; }
Nginx + php-fpm on Amazon Linux = exited on signal 11
Amazon Linux lastestPHP 5.4.19 (cli) (built: Sep 3 2013 23:19:23)nginx version: nginx/1.2.9installed PHP-FPM: PHP 5.4.19 (fpm-fcgi) (built: Sep 3 2013 23:22:01)phpinfo() is workingpma.nginx.conf:server { listen 80; server_name pma.my.server; root /usr/share/phpmyadmin; index index.php; charset UTF-8; access_log /va...
it appears that PHP is trying to write session data to disk in a directory that's not actually writable, namely/var/lib/php/session.Thanks to Michael Hampton
Nginx authentication except those on local network
Coming from apache2 one feature I can not achieve; require authentication only to external access but free access to users on my local network. Any ideas how to handle easily this scenario?Any help would be appreciated.
I've deleted my previous answer and would like to suggest a solution I've provided belowI did a little search and found this solution to your problem -In code, where you useauth_basicdirective, make such changes:satisfy any; allow 10.0.0.1/8; // give access for all internal request deny all; auth_basic ...
How to configure GitLab as a subdomain in nginix.conf
I was using Apache2 before I installed GitLab on my VPS. I just want to make GitLab a subdomain of my site (git.example.com) and have my main site (www.example.com) look at /var/www/html/index.htmlHere is my nginx.conf file as of now:user www-data; worker_processes 1; error_log /var/log/nginx/error.log; pid ...
Here is my setup that works on a subdomain.server { listen 80; server_name gitlab.example.com; root /home/gitlab/gitlab/public; # individual nginx logs for this gitlab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; location / { # serve static files f...
Nginx: "Resource temporarily unavailable" using a Samba share
I am developing on aNginxweb server with aSambashare.Whenever I edit a CSS or JS file, I got this error when I reload my website (F5).2012/04/18 11:15:38 [crit] 29607#0: *47708 open() "/var/www/[...].js" failed (11: Resource temporarily unavailable), client: 192.168.[...], server: [...], request: "GET [...].js HTTP...
These two settings solved the same problem for me:oplocks = no level2 oplocks = no
Is it possible to use modify nginx config file and use X-Accel-Redirect on Heroku?
Readingthis articleon nginx website, I'm interested in usingX-Accel-Redirectheader in the way that Apache or Lighttpd users might use theX-Sendfileheader to help with the serving of large files.MosttutorialsI've found require you to modify the nginx config file.Can I modify the nginx config file on Heroku and if so, ho...
Although Heroku seem to be using Nginx for their reverse-proxy component, the thing about a platform-as-a-service stack like this is that no individual tenant has to (nor even gets to) configure or tune distinct elements of the stack for any given application.Requests in and out could be routed through any number of di...
A little confused about trailing slash behavior in nginx
Trailing Slash in nginx has been giving me some sleepless nights lately. Requesting some help with thisQuestion:Strange trailing slash behavior inproxy_pass.So why would this work :location /myapi/ { proxy_pass http://node_server8/; }and this won'tlocation /myapi/ { proxy_pass http://node_server8; ...
They are totally different.In the firstproxy_passstatement you have included a URI parameter with a value of/. In the second you haven't.When you giveproxy_passa URI parameter (within a prefixlocation), it transforms the requested URI similarly to thealiasfunction, whereby the value of thelocationdirective is substitut...
Nginx status endpoint running inside Docker
I'm new to Nginx, which I'm running in a Docker container to serve a simple website. I want to add an/healthendpoint that simply returns status 200 + some arbitrary content.I copied and adjusted the standardnginx.conffrom/etc/nginx/by addingserver { location /health { return 200 "alive"; } }at the botto...
The problem was with my Nginx Docker setup/configuration: I am usingnginx:alpine, which has the configuration files at/etc/nginx/conf.d/. There,default.confdefines the default configuration of Nginx. So, I had to removedefault.confand copy my configuration there instead. In theDockerfile:COPY nginx.conf /etc/nginx/conf...
Recommendation to improve wp-admin panel performance
Recommendation to improve wp-admin panel performance : Please provide the suggestions and way to identify the bottlenecks in wordpress admin panel issue. It is a multisite and it has 3rd party plugins enabled . How to identify plugin conflict and which plugin is causing perf/ memory issues. All these php-fpm, nginx ar...
Thanks for all your inputs. I have identified the problem and resolve it . The problem is with the Network file system and the php script takes more time to read it because the uploaded assets total size is in GB's and the wordpress framework built in Filter will do recursive call to calculate the size. I have used De...
Compressing assets with NGINX in reverse proxy mode
I'm using NGINX as a reverse proxy in front of a Node.js app. The basic proxy works perfectly fine and I'm able to compress assets on the Node server withcompressionmiddleware.To test if it's possible to delegate the compression task to NGINX, I've disabled the middleware and now I'm trying to gzip with NGINX with the ...
Try to add theapplication/javascriptcontent type:gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/json application/xml application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xm...
Nginx: enable/disable caching depending on HTTP method
I asked this question on serverfault, but nobody answered. Hope, stackoverflow people know Nginx better :)I want to handle all [GET] requests to /api from cache and handle all other requests as in last location block (without cache). All the requests to /api with methods PUT, POST, DELETE also have not to use cache.I s...
It's pretty simple thankfully. Nginx's modules (proxy, fastcgi, uwsgi etc) all have the ability to inform a request not to use the cache.location ~ ^/api { root /var/www/project/web/app.php; fastcgi_send_timeout 600s; fastcgi_read_timeout 600s; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_split...
docker nginx container not receiving request from outside, connection refused
I have a running nginx container:# docker run --name mynginx1 -P -d nginx;And got its PORT info bydocker ps:0.0.0.0:32769->80/tcp, 0.0.0.0:32768->443/tcpThen I could get response from within the container(id: c30991a04b2f):docker exec -i -t c3099 bashcurl http://localhost=> which return the defaultindex.htmlpage conten...
If you are On OSX, you are probably using a VirtualBox VM for your docker environment.Make sure you haveforwarded your port 32769to your actual host (the mac), in order for that port to be visible from localhost.This is valid for the old boot2docker, or the new docker machine.VBoxManage controlvm "boot2docker-vm" --nat...
Nginx: What is the X-Forwarded-For alternative for WebSockets?
Is there any way to pass client identity to Nginx (to get sticky session) when using WebSockets? Something similar to "X-Forwarded-For" header for HTTP ?
Websockets start their life under a HTTP upgrade handshake. Once the handshake is successfully completed you get back a long running bidirectional websocket connection.If you use Nginx as a proxy for websockets then you can also use "X-Forwarded-For" but only on the handshake. See for examplethis simple configuration:#...
Restricting direct access to port, but allow port forwarding in Nginx
I'm trying to restrict direct access to elasticsearch on port 9200, but allow Nginx to proxy pass to it.This is my config at the moment:server { listen 80; return 301; } server { listen *:5001; location / { auth_basic "Restricted"; auth_basic_user_file ...
add this in your ES config to ensure it only binds to localhostnetwork.host: 127.0.0.1 http.host: 127.0.0.1then ES is only accessible from localhost and not the world.make sure this is really the case with the tools of your OS. e.g. on unix:$ netstat -an | grep -i 9200 tcp4 0 0 127.0.0.1.9200 *.* ...