New answers tagged

0

Try using the nginx upload module. You'll need to build nginx including the module --add-module=path/to/nginx_upload_module You can then tell it where to store uploads upload_store /home/wherever This was discovered using Google with 5 minutes of research. This is always recommended before asking a question on SO, because it's faster and you may learn ...


0

You need to use an alias instead: location /assets/ { alias /communities/$host/; }


1

This is the default behavior of web servers showing directory indexes, for example Apache does the same. Whenever you request just "directory", it will redirect you to "directory/" like that. Apache documentation is explicit about it, e.g. https://httpd.apache.org/docs/2.4/mod/mod_dir.html says A "trailing slash" redirect is issued when the server ...


0

Use an appropriate directory to store your web documents, so that you do not need to disable SELinux. These directories are: /var/www /srv/www And if you have problems, don't grope around blindly; check the logs to find out the specific problem.


0

The best practice is not route traffic to S3 through your server, which will only serve to slow it down. You can load assets from S3 over SSL using a URL structure like this: https://s3.amazonaws.com/example-bucket-name/example.jpg It's also advised to serve your static content from a separate domain, as browsers open up a limited number of parallel ...


1

You should add a second filter to your ps command : ps -ef | grep -v grep | grep nginx You would then realize the absence of nginx process


2

Nginx is not running. You search the process table for nginx with grep nginx, but this causes the string nginx to appear in the process table, namely in the grep process. If you look careful, you can see that grep nginx is listed as the command for the process in question. Naturally, this process is short lived and the next time you run the search, it will ...


-1

Even though I disabled SELinux by modifying the config file it was still enabled. I had to run the command 'setenforce Permissive' and it worked!!


0

Yes. For this to work, you should read the documentation about location matching.


0

Here my question was answered stackoverflow.com/a/35291314/1517230 by clever stackoverflow users :) 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_path_info ^(.+\.php)(/?.*)$; include fastcgi_params; # Don't cache ...


1

rewrite in nginx doesn't lead to 301 status in general (unless explicitly configured), so 301 is probably caused by other parts of your nginx config. rewrite is the proper way to achieve what you want, your aproach is right.


1

Sorry to give a not-answer, but I don't think there is a yum-friendly way to install headers_more(but it would be great if I were wrong on this!), unless you want to go through the effort of creating the nginx+headers_more RPM yourself(and someone has worked on this apparently: https://github.com/feedforce/nginx-headers-more-rpm), but you need to maintain it ...


0

This solved my issue. Sad to say that there is not many articles related to these issue, even nginx doesn't provide user friendly Help/Tutorials. location ~* ^/-PageOne.html { rewrite ^ /seo.php?page_id=1 last; } Hope this helps!


2

ngx_http_referer_module is another way to do it. Example from Referer Spam Blocking: location / { valid_referers none blocked *.badreferer1.com badreferer2.com *.badreferer3.com badreferer4.net; if ($invalid_referer) { return 403; } }


1

Have you tried simple? location = /super-shots.xml { proxy_pass http://mybucket.s3.amazonaws.com/depth0/depth1/depth2/sitemap.xml; } You don't need anything on local file system. Your problem is that request /super-shot.xml matches location ~* \.(js|ico|...xml.... Using = suffix we tell nginx that this exact request should be processed here and it ...


1

Nope. Apache won't be better, however it can do the same work exactly. The canonical way of fullfilling your wish is to create different servers in nginx, and proxy to different backends according to the Host HTTP header, along with passing that header, if necessary: server { listen 80; server_name myshoppingapp.com; proxy_set_header Host $host; ...


0

Use proxy_intercept_errors and proxy 500s to a server that has caching enabled.


0

I edited my config as following: server { listen 80; server_name example.com *.example.com; return 301 https://example.com$request_uri; } server { listen 443; server_name example.com *.example.com; <-your_other_site_configurations-> ... ... Now it is working perfectly! Hope it helped others too!!


0

I know its very late for an answer but I had this issue and came across this question. You could use proxy_next_upstream_tries 2; http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream_tries


0

Create a permanent redirect: server { charset utf-8; listen 80; listen 443 ssl; server_name www.example.com; rewrite ^/(.*) https://example.com/$1 permanent; } server { charset utf-8; listen 80; listen 443 ssl; server_name example.com; location / { # this serves the actual content ... ...


1

You asked for the URL path to be appended to the redirected URL, by using $request_uri. Thus, if you go to http://graphwhy.org/ you're redirected to https://www.surveymonkey.com/r/nationaldebt/, because the requested URI is /. Further, if you go to http://graphwhy.org/because then you are redirected to https://www.surveymonkey.com/r/nationaldebt/because, ...


0

There were a few things going on. location / was being cached which caught the traffic initially. Adding the following rules worked, but only after clearing the cache used initially for some reason I still have yet to figure out. location /broadcast/ { # Proxy proxy_next_upstream error timeout http_404; proxy_pass http://$host$request_uri; ...


1

This is because of the try_files madness and other questionable approaches. Remove all of your exercises and make it canonical: location / { index index.html; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php; } } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME ...


0

The FIRST https request is really slower because of the TLS negotiation, and your benchmark only test that. A real life client will make a lot of request (one for the html page, and several for js/css/images). With TLS session tickets, that TLS negotiation is skipped after the first request. Until the expiration of the session ticket, https requests will ...


3

Your server_name needs to match the CNAME record you created, not the target of the CNAME.


0

That config looks very familiar - I posted most of it in another thread :) Alas it's missing an important part. location = /wp-login.php { fastcgi_keep_conn on; fastcgi_intercept_errors on; fastcgi_pass php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # No caching more_clear_headers ...


0

You should pass those parameters in a hidden format using either POST or SESSIONS. They appear in the address because they are being passed using a GET request, it's good for debugging but not for long term use as they are easily copied and make it easy for someone to login as someone else. Using POST or SESSIONS will make the URL appear as you want. HTTP ...


0

It turns out that this problem was caused by the way Gunicorn was set up. I was told by my peers that they had set it up with TLS encryption, but upon closer inspection it wasn't using any encryption at all. The [::1] in the error was likely cased by Nginx falling back to IPv6 after failing an IPv4 connection. Simply changing the proxy_pass from https to ...


6

Benchmarks are lies, don't reflect the reality but might be a useful tool to detect bottlenecks. But you have to understand the benchmarks. Given that you omit essential details needed to understand the benchmark results it might be that you don't really understand what might affect the results of the benchmark. Especially information about the size of the ...


2

The keys_zone parameter of the fastcgi_cache_path directive specifies a memory zone to store cache keys. Its size indirectly limits number of items the cache can store (1 megabyte ~ 8k items), but not on-disk size of the cache. To limit on-disk size use the max_size parameter: fastcgi_cache_path ... max_size=2048m; See fastcgi_cache_path documentation ...


0

It's not always that the SCRIPT_FILENAME is wrong. It may also be PHP is running as the wrong user/group. This example is specific to Mac OS X, which in my experience is the most troublesome to setup (Debian is easy by comparison) - I've just upgraded from PHP 5.6 to 7.0, using homebrew and the excellent josegonzalez packages. The problem was that a new ...


1

You CURL'd the wrong URL, add the www. When you do that the cache works and you can see it in the headers. Add these lines to your file to change your caching slightly. # Determines in which cases a stale cached response can be used when an error occurs during # communication with the FastCGI server fastcgi_cache_use_stale error timeout invalid_header ...


1

Proposed solution (showing only the location blocks): location ~ ./$ { rewrite ^(.*)/ $1 last; } location / { if ($request_uri ~ ^(.*)\.(php|htm)) { return 302 $1$is_args$args; } try_files $uri $uri/index.html $uri/index.htm @php; } location @php { try_files $uri.php $uri/index.php =404; include /etc/nginx/fastcgi_params; ...


1

First, you configured nginx to not cache 301 redirect responses. If you want to cache these, (and you should!) then set it up: fastcgi_cache_valid 301 30d; Second, WordPress sent explicit instructions to not cache the redirect, so it would not be cached anyway.


0

Found the problem. I was confused over how portmapping works. The working config: docker-compose.yml: httpd: build: httpd ports: - "8080:8080" links: - "server_jenkins" - "clients_jenkins" restart: always server_jenkins: image: jenkins restart: always clients_jenkins: image: jenkins restart: always nginx.conf: http { ...


1

The following line adds a ? to the end of any externally presented URI ending with .php: if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1?$args; }`. A quick fix would be to use $is_args instead of the ?. See this document for details.


2

To answer your question: "Why it shows upstream: "http://a.b.c.d:10062/"? Should not it show "wss://a.b.c.d:10062/"?" Nginx displays the URI that way because that's how it's provided in the configuration: proxy_pass http://a.b.c.d:10062; I don't think that detail is an indicator of your problem, since it seems you've followed the recommended syntax ...


0

Try increasing the max number of open files: root@server $ sysctl fs.file-max=3000000000 Edit: You can usually have these changes be made permanent by adding the line to /etc/sysctl.conf: fs.file-max=1234567890


2

Your problem is that you are serving your static content off the backend app server. So when the backend app server can't respond because it's busy, Nginx prepares a 502 response. Your configuration directs Nginx to serve a particular HTML in that case, which in turns loads more static content from Nginx. Those requests are then proxied to the app server and ...


0

You can't control the storage inside the Nginx FastCGI cache, but if you enable Gzip compression, Nginx will deliver the pages compressed to client.


0

For me it worked without the equals sign like this: location /old-url { return 301 /new-url; }


0

You are questing /piwik.php (if you requesting /, /piwik.php is marked as default). /piwik.php is the tracker. You have to request /index.php before and use web administration interface to produce the config file.


0

Try something like this - I can't guarantee it will work, but it's worth a shot. Basically it's saying "send requests for the UI folder to this other server". You may need the rewrite in the other answer as well or instead. location /ui { proxy_pass (etc); }


0

I put this inside my https server block and it redirects the given url, in this example https://subdomain.domain.com to https://subdomain.domain.com/ui and send a permanent flag to remote browser for future reference/speed. I assume that is why atleast rewrite ^/$ /ui permanent; or rewrite ^/$ /path permanent; Full Configs: server { listen ...


3

That level of latency is just fine for talking to a database. Many high traffic sites use a similar architecture and may even have higher latencies to their databases. I wouldn't worry about that. The only thing I would worry about is whether others can sniff the traffic. On OVH's network it's not likely, as their switches generally don't flood unwanted ...


0

I am deleting my previous answer as I was answering something completely different. I found your problem, its the http://127.0.0.1 and ports which is wrong, 127.0.0.1 inside nginx's conf means the httpd container itself in this case not the host. If you re-define that to server_jenkins and clients_jenkins and also suffix the 8080 port for both of those, ...


1

You simply need a new server block with the server_name set to the second domain and a proxy_pass in the location. If you need it to be https you can list either another certificate, or the same certificate if it has the correct alternate names. This is covered in the Nginx beginners guide. server { server_name example.com; listen 80; listen 443 ssl ...


4

Nginx is respecting file permissions. Nginx is running as www-data and Linux is enforcing the file permissions. The issue here is two goals that conflict. Expectations need to be changed. First, you want the files to "inaccessible to the world" via the web browser. This implies that they can't be readable and accessible by the www-data user. Second, you ...


2

You need to internally rewrite the URI: location ~ /tutorialPage { rewrite ^ /tutorial.html last; } The index directive determines the default action when encountering a directory, which is not the case here.


2

You will also need to run: apt-get install php5-cli=5.3.10-2 php5-fpm=5.3.10-2 php5-common=5.3.10-2 php5-readline=5.3.10-2 These were still on the 5.6 version, that's why you still see 5.6.



Top 50 recent answers are included