We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [nginx]

nginx (pronounced “engine-x”) is a lightweight, high-performance Web server/reverse proxy and e-mail (IMAP/POP3) proxy, licensed under a BSD-like license.

Filter by
Sorted by
Tagged with
28
votes
2answers
87k views

Can I skip the PEM pass phrase question when I restart the webserver?

After buying a multi-domain SSL certificate I have started testing it with the Nginx webserver (following documentation in their SSL wiki page). Everything is fine, it works and I get a green ...
19
votes
1answer
4k views

Google .dev domain strangely redirects to https

I bought a .dev domain today @ domains.google. I also set up a dedicated nginx web server to which the .dev domain points (A records). Very strangely, I can't access my nginx welcome page using my ...
15
votes
7answers
28k views

How to block baidu spiders

Most of my visits are from baidu spiders. I don't think it helps search engines at all so I'm thinking of how to block them. Could this be done via iptables? I'm using nginx as my webserver.
13
votes
5answers
914 views

Is it worth looking into a webserver other than apache?

I've traditionally deployed my sites under apache, simply by default. I've heard things about NGinX though and I'm wondering under which conditions it would be superior. In addition to apache and ...
10
votes
2answers
6k views

Why there suddenly were so many 400 request in my access log?

Below are little part of my access_log 118.186.8.50 - - [19/Dec/2011:22:42:57 +0800] "-" 400 0 "-" "-" 05 118.186.8.50 - - [19/Dec/2011:22:42:57 +0800] "-" 400 0 "-" "-" 06 118.186.8.50 - - [19/Dec/...
7
votes
2answers
7k views

More Secure NGINX Authentication than auth_basic

I've been trying to come up with the most secure method of authentication to my reverse proxy in NGINX. I've been using ngx_http_auth_basic_module so far without any issues, but there are apparently ...
6
votes
1answer
23k views

Nginx negating condition/ if else

I've came into situation where I cannot find a way around it, neither with tons googling. valid_referers none blocked something.com; if ($invalid_referer) { rewrite ^ /leech.jpg; expires ...
6
votes
2answers
12k views

Getting IP address and location of my own server instead of visiting user's

I have a MEAN Stack application deployed on a server and am using Nginx as proxy server to handle the request and redirect to application's particular port. For example: User accesses the URL http://...
6
votes
1answer
229 views

Where are these spammy posts generated from?

While doing a a random Google search, I realized that my WordPress blog is populated with several spammy posts. Ex: (intentionally delinked) http://example.com/2016/02/06/free-download-wallpaper-...
6
votes
2answers
5k views

Difference Between php_admin_value[memory_limit] and php.ini memory_limit

I have Nginx + php-fpm + Mysql. With the php memory settings, I always set this in php.ini like this: memory_limit = 256M Now, I bumped into another similar looking setting in pool.d/www.conf file ...
5
votes
2answers
2k views

How can I serve all resources under HTTPS instead of HTTP without changing their URLs in the HTML code

I know that by using an .htaccess file I can redirect everyone to https://. However, my SSL certificate complains if all the content isn't served under HTTPS. Is there a way to convert all the ...
5
votes
1answer
1k views

Nginx Reverse Proxy for Tumblr

I'm currently trying to set up a reverse proxy redirecting a domain to a tumblr blog. I've set up NGinx using this Gist. My nginx configuration looks like so: upstream tumblr { server 66.6.44....
5
votes
1answer
489 views

Nginx and Google Appengine Reverse Proxy Security

The scenario is that I have a Google compute node running Nginx as a reverse proxy to the google appengine. The appengine is used to service REST calls from an single page application (SPA). HTTPS ...
5
votes
0answers
516 views

Using Nginx to rewrite a friendly URL to index.php handler gives 404 errors

I am having some issues getting the below to work the way I expect. What I am trying to do is take a url like https://example.com/TOPIC/courses/details/143911 but have it sent to php with the URI ...
4
votes
2answers
4k views

What is the default behavior of Cache-Control

If no private nor public were defined in the cache-control, e.g. Cache-Control: max-age=31461276 What is the expected behavior?
4
votes
1answer
227 views

Preventing URLs ending in “/” from search engine indexes with robots.txt or rewrite rule

Is there a programmatic way to easily deal with the issue of search engines considering pages where the page works with and without the trailing slash duplicates like via a robots.txt or Nginx rewrite ...
4
votes
1answer
194 views

When I search on my domain name in a browser, the IP address is returned for my site hosted with GoDaddy and NGINX

The IP address of my site is returned when I do domain name search in my browser. I am using: GoDaddy Hosting Nginx Node.js Obviously I would like the domain name and not the IP address, how can ...
4
votes
1answer
171 views

Nginx subdirectory wordpress wp-login redirects to 404 not found

server { location / { try_files $uri $uri/ @extensionless-php; } location /shop { try_files $uri $uri/ /shop/index.php?q=$uri&$args /shop/index.php?q=$uri&$args; ...
4
votes
1answer
566 views

Nginx PHP setup: no input file specified

I inherited this web server with Nginx and I'm trying to get a new basic PHP site setup on here. I've followed instructions here. https://gist.github.com/GhazanfarMir/03bd1f1f770a3834d47274586d46ea62 ...
4
votes
1answer
618 views

Nginx rewrite problem - displaying same page with or without .php extension after rewrite

I have implemented the following Nginx code: location / { try_files $uri $uri.php $uri/ @extensionless-php; index index.html index.htm index.php; } location ~ \.php$ { try_files $uri =...
4
votes
1answer
540 views

How to make my websites content available as Tor .onion and Clearnet .com?

I'm running a website with Nginx which I would like to be accessible by Tor and by Clearnet. Currently it's only reachable by Clearnet, e.g. www.example.com. Of course people just can go to www....
3
votes
3answers
17k views

NginX redirect to PHP file if image does not exist on file server

This is what I am trying to do. I am not familiar with Nginx enough to create custom rewrite rules like you can with Apache. It would be greatly appreciated if someone could help me with the Nginx ...
3
votes
1answer
1k views

What does the '^' mean in “rewrite ^ http://example.com permanent;”

I found some configuration of nginx contains: if($args ^~ post=140) { rewrite ^ http://example.com/ permanent; } What does the ^ mean in rewrite ^ http://example.com/ permanent?
3
votes
1answer
505 views

NGINX - Rewrite .js.php file to .js

I have a dynamically created file start.js.php?c=21 and I would like to rewrite it's extension (to start.js, with query params). Is that possible? Is that a good method having such a rewrite? Is ...
3
votes
2answers
3k views

nginx http to https redirect - just isn't working

I am running my own webserver with nginx on ubuntu 17.10. I have opened ports 80 and 443. Trying to get the HTTP to HTTPS redirect working, but everthing i seem to have tried fails. i am still ...
3
votes
1answer
4k views

Rewriting image URLs in nginx from a shortened URL to a specific directory

I'm using an image serving application on nginx/1.4.6 (Ubuntu), but it was made for Apache2. Images are uploaded to directory "/imageshare/images/extension/" where the filename is randomly generated, ...
3
votes
1answer
272 views

nginx: 301 redirect to non-www, SSL urls on default_server(s)

My goal is to have nginx primarily return a check for all requested URLs that start with http:// and/or contain //www., and 301 redirect them to the URL where //www. is replaced by // and http:// ...
3
votes
1answer
65 views

The effect of removing many URLs from google search console

I have been working as a web developer for several years, fixing issues, errors, and increasing page load speed etc. but I'm kinda new to SEO and Google Search Console. I have a client who is using ...
3
votes
1answer
762 views

Adding “expires” directive in Nginx conf for assets causes “404 not found” errors

I have a live Django site running gunicorn, nginx, supervisord. I am trying to implement the suggestions found here to increase my page speed score by using gzip in nginx. The resulting config file is ...
3
votes
2answers
78 views

Is SSL a Major Contributing Factor to Website Speed

I have nearly a perfect score on Pingdom Results: https://tools.pingdom.com/#!/tU1lz/https://varmag.com/ If I'm not mistaken, it looks like SSL is what's slowing me down? Doing some research, If I'm ...
3
votes
1answer
665 views

Why do some Nginx configurations block download agents using Wget?

I noticed that some Nginx configurations block download agents using Wget like this: if ($http_user_agent ~* LWP::Simple|wget) { return 403; } Why block Wget? If I use the above code in my Nginx ...
3
votes
1answer
48 views

Gzip not working on nginx CentOS despite configuration to enable it

gzip shows as not enabled on my vps site and not even the tech support of my host, asmallorange, can figure out the cause of my problem. I've documented my exact set-up (nothing more than this was ...
3
votes
1answer
1k views

Nginx fails to start HTTP/2 server due to error: unknown log format

In our hosting server from the Plesk cpanel, Nginx is configured to work as a reverse proxy engine. As I need to enable HTTP/2 that can speed up the loading time of Plesk and hosted websites. ...
3
votes
2answers
2k views

Using one index file in all directories and subdirectories

I have an index.php file, which processes content of a directory it is located in and renders output to the browser. The problem is that the directory structure it is supposed to serve is rather ...
3
votes
2answers
60 views

When moving a load balanced PHP site from Apache to Nginx, how does the code have to be modified?

When moving to Nginx with multiple php-fpm servers from a more "traditional" Varnish + multiple Apache2 / mod_php setup: Must we expect to rewrite parts of our software? I just discovered that many ...
3
votes
1answer
577 views

Cloudflare infinite redirect

Background I recently migrated my websites to an all Docker environment using haproxy as the front end load balancer. I have SSL certificates for all domains issued by Let's Encrypt and everything ...
3
votes
1answer
720 views

Cache an external site that may have a mobile version

In continuation of the answer for the "Nginx Reverse Proxy for Tumblr" question, what is the best way to cache a web-site like Tumblr with nginx, which returns distinct results depending on the User-...
3
votes
1answer
264 views

Why SPDY-enabled pages are not loading faster?

I've just enabled the SPDY module on nginx, as explanained on the SPDY module site. I expected a speed enhacement on my site, but I haven't noticed it. Using Firefox 25 and Firebug, I tried to take a ...
3
votes
0answers
34 views

405 for POST requests, download triggered for GET requests for specific php file only

Apologies, I know this is a basic question, but I'm learning nginx! I've inherited a Nginx driven site, the problem is that when browsing to a specific php file it initiates a download. The file, ...
3
votes
0answers
30 views

Server receiving hit from its own DigitalOcean public IP Address. Why is that and how to resolve this?

I have a MEAN Stack application deployed on a Digital Ocean Droplet and I am using Nginx as proxy server to handle the request and redirect to application's particular port. I wrote a short script in ...
3
votes
0answers
48 views

Pagespeed not compressing images

Original image bart-had-a-groove.gif size is 753.43 KB. Processed image bart-had-a-groove.gif.pagespeed.ce.gB3ARqAHA8.gif size is still 753.43 KB. Mods used: pagespeed DisableRewriteOnNoTransform ...
3
votes
1answer
3k views

Nginx: set Content-Type by URI problem

I'm setting up small personal file hosting, I made a backend to store uploaded files by their hash directly on the HDD like /f/ab/cd/ef012345678..., but without file extensions and generate an URI ...
3
votes
1answer
2k views

nginx rewrite for an url with parameters

I have two types of URL and want to rewrite it for friendly URL. 1. The first: https://example.com/folder/myfile.php?id=xx&param1=yy I want to rewrite to: https://example.com/folder/myfile/xx/...
3
votes
1answer
23 views

Mediawiki - Method for $wgActionPaths on nginx

I'm trying to set up action path rewriting on my mediawiki 1.33 install with nginx 1.14.0 on Ubuntu 18.04 with php 7.2fpm. All the documentation I've been able to find on mediawiki.org and via ...
2
votes
3answers
3k views

How to block a user-agent that has a spacing in its name?

I got a hit from a crawler with a user-agent called DV CRAWLER which is an abvious a spam-bot. I tried to block it in both .htacess and nginx configuration as I'm running nginx as a reverse proxy in ...
2
votes
2answers
259 views

Google indexed my site through a subdomain, how to fix?

So I recently switched to nginx but I didn't specify my site_name in nginx.conf, which I've learned is interpreted as a wildcard domain, meaning you can access the site through any subdomain. I had a ...
2
votes
2answers
3k views

Share a configuration among different “server” directive

I'm trying to share a variable across different "server" blocks, http { set $bad_ua "..."; server { if ($http_user_agent ~ $bad_ua) { ... } } } But nginx says ...
2
votes
1answer
131 views

Setting up Nginx Load Balancing

I'm setting up an Nginx web server and and want to perform load balancing using the round robin method. This is what I have found thus far: upstream backend { server backend1.example.com; ...
2
votes
2answers
128 views

Why do servers need to know their domain?

Besides routing traffic, why do servers need to be configured with the server name? It seems like a waste in all cases except for routing or hosting for a TLD. Nginx example: server { listen 80; ...
2
votes
1answer
8k views

How to map requests to an external directory

I have a directory/application that is located outside of the web root directory of my site. Say the site is here: /var/www/site/htdocs/ And the external app is located here: /var/www/apps/coolapp/...