New answers tagged

0 votes

nginx append query parameter to a react application

If you want React to see the query parameter you will need to use redirect or permanent. The other modes of rewrite are internal to Nginx. See the rewrite documentation. To protect against a ...
0 votes

ssllabs.com IPv6 issue: Unable to connect to the server (nginx)

Before anything, ensure the basics: you have A/AAAA records correctly pointed your nginx is listening on ipv6 (as of some ancient version, like 1.11 or so, ivp6 is baked in by default so there's no ...
  • 1
1 vote

How do I disable just one cipher out of OpenSSL TLSv1.3 list?

As of nginx 1.19 this is possible: ssl_conf_command Ciphersuites TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256; Now you will be able to score 100%, but you will be violating standards. So after ...
0 votes

PHP Slim framework on NGINX with a specific location directive

You should use full filesystem path with the root directive. Also remember, nginx will append the path component of URL at the end of directory specified in root. If your root is /var/www/slim in /...
1 vote
Accepted

Nginx - fastcgi cache not working for rewrite enabled php page

Your location = /inc/special.php passes requests directly to fastcgi server, therefore there is no caching. Furthermore, you need to check the HTTP caching headers set by special.php. If the HTTP ...
0 votes
Accepted

New user fails authentication with Gerrit setup using proxy HTTP while other users work

I found the answer to this - posting here to help anyone else with the same issue. It turns out that the user account requires a "gerrit:" external ID in order to successfully log in, but ...
  • 109
0 votes

Unexpected graceful nginx shutdown

There is some problem in the Passenger module in your nginx, which is likely triggered by some part of your website code. Try upgrading nginx and Passenger to most recent version and see if it becomes ...
0 votes
Accepted

How can I see the memory content of nginx process?

It seems my problem was related to Michal256's post from the ModSecurity memory leak link provided by @AlexD. I was loading modsecurity for every server context. I've changed it to the http level and ...
  • 123
0 votes

Check nginx active connection without HttpStubStatusModule

Add the following to the nginx server block location /nginx_status { # Turn on stats stub_status on; access_log off; allow all; } we can check the connections ...
0 votes

NGINX redirect 404 errors to an external URL

error_page 404 = @redirect; location @redirect { return 301 https://yoururl.com; }
  • 101
0 votes

How can I replace Access-Control-Allow-Origin header in proxy response with nginx

Folllow exe-dealer answer and if you are using php to set header you can make: # always set a new header add_header access-control-allow-origin "*" always; # remove header that came from ...
0 votes

Is it possible to host a vpn on a website server running on nginx?

Yes, it's possible. HTTP servers use port 80 for http, and 443 for https. None of these ports is required for VPN. Which port VPN's default to depends on the solution, and for many of the solutions, ...
  • 3,820
0 votes

Nginx rule to serve WebP images when available

After several years, the solutions to conditionally serving WebP images have not improved, and always requires some sort of http_accept that checks if the client browser supports it and then try_files ...
0 votes
Accepted

Nginx proxy_pass doesn't always work when using a variable for the host

I finally found the solution for this problem, that I only realised after posting it. The problem for me was defining the variable in the location block. Defining it outside the location block was ...
  • 123
0 votes

Centos 7 server with Nginx reports errors when updating packages

yum remove nginx-mod-http-perl* yum remove nginx-mod-stream* yum remove nginx-mod-mail* yum remove nginx-mod-http-image-filter* yum remove nginx-mod-http-xslt-filter* also don't panic nginx-all-...
0 votes

How to proxy wss websocket to a http forward proxy using Nginx?

Yes it's possible. This is taken from a working configuration.... proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; ...
  • 19.9k
0 votes

ONLYOFFICE - JWS secret doesn't work (can connect without)

I have been trying to resolve the same issue - I have a docker container setup so based on the feedback - I was able to locate my token as per the screenshot provided and instead of modifying any file ...
  • 1
0 votes
Accepted

NGINX not setting Cache-Control header consistently

The content-type that you are trying to set cache has charset. This should also be part of the rule: map $sent_http_content_type $expires { default off; text/html ...
0 votes
Accepted

Cannot read wordpress PHP files in NGINX - HTTP error 500

I have figured it out from looking at the NGINX error logs in the "warn" scope, one configuration file for wordfence security plugin was using a hardcoded path to my website, and since I ...
  • 1
0 votes

How do I redirect "old.foo.com/foo" to "new.foo.com/foo" with a NGINX K8S ingress, without breaking cert-manager?

After some blind experimentation, it actually seems to work to place $request_uri into the target URL in the "permanent-redirect" annotation. I'm guessing it's passed directly into the NGINX ...
  • 1,098
0 votes

How to redirect specific page to another url on nginx?

There are several ways of doing this, pick one that applies best to your situation. Edit your nginx config file and add the necessary info to it. server { # Temporary redirect to an individual page ...
  • 141
0 votes

How do I redirect "old.foo.com/foo" to "new.foo.com/foo" with a NGINX K8S ingress, without breaking cert-manager?

With plain nginx you would have a separate server block for HTTP: server { listen 80; # Serve ACME verification requests via HTTP location /.well-known { try_files $uri =404; }...
0 votes

Cannot read wordpress PHP files in NGINX - HTTP error 500

you should not use this kind of permissions... please verify the needed permissions for your wordpress instance. Please check if php-fpm deamon is running... systemctl status php8.1-fpmd or so... ...
0 votes

how set separate log file, to log 400 bad request errors in nginx

What is needed is to setup a separate access log for the errors. Terminology can be confusing, to quote the documentation: NGINX writes information about encountered issues of different severity ...
  • 538
0 votes

Nginx doesn't rebound from 502 Bad Gateway

This answer describes a solution to a problem that matches the title and the description. It is not an attempt to answer Rob's question 9 years later, hoping it may be helpful to others. The solution ...
0 votes

Nginx Wordpress Subdir + wp admin

For sure you need root /var/www/html/wordpress/public_html/blog; in the block location /blog {} Moreover the block location ~ \.php$ should looks like below: location ~ \.php$ { try_files $uri =...
  • 1
0 votes

Redirecting specific URLs to different directory

Searched the web extensively for a solution to this but couldn't find one. Came up with a solution that works. Consider the case where your website's root is set to /data/mywebsite, so a request to ...
0 votes

Not able to change the redirect path using ngnix on docker

I'm assuming your nginx is listening on Port 80/443. Your nginx can't magically handle requests that come directly to the port 8081. You need to configure this directly on the service that is ...
0 votes

redirect http to https in nginx load balancer

The preferred pattern to do HTTP to HTTPS redirect is as follows: server { listen 80; server_name example.com www.example.com; return 301 https://www.example.com$request_uri; } You need ...
0 votes

Nginx directory (21: Is a directory)

This problem can also be solved by ensuring that the folowing line is not commented : pid logs/nginx.pid;
  • 101
0 votes

httpd: Connection attempts using mod_proxy:

I suggest checking if your server is vulnerable to Proxying this way : $ curl -kx http(s)://<your-server-ip>:<your-server-port> http://ifconfig.me And $ curl -kx http(s)://<your-server-...
0 votes

Access nginx from local network

Using the Hosts file is a lot of work if you have multiple hosts (e.g., Classroom environments or you don't have enough rights to do so). An easier and faster way to accomplish this is to use https://...
0 votes

DNS shows wrong IP addresses on different machines

We figured out the problem. The problem is that our domain has two NS and they return completly random the correct or incorrect IP. It isn't a problem of the client, which DNS, or from which ISP you ...
0 votes

Downloadable font rejected by sanitizer

For those lost souls of you that still got "Downloadable font rejected by sanitizer" while hosting fonts on a nginx server. I checked my nginx logs /var/log/nginx/error.log, guess what: ...
  • 1
0 votes

DNS shows wrong IP addresses on different machines

Using DnsChecker I can see that major DNS providers (Google, CloudFlare, OpenDNS) report the IP for the domain correctly, as does my ISP. I suspect the problem is with your client. What problem is ...
  • 30.4k
1 vote
Accepted

Access nginx from local network

you can add on the computer in the LAN that you want to access your website from the following line: 10.120.11.110 example.com to /etc/hosts (or C:\Windows\System32\drivers\etc\hosts if on Windows)
0 votes

nginx error_log reports “bind() to 0.0.0.0:80 failed (48: Address already in use)”

If you don't find nginx in Network tab see this Run ps -ef | grep nginx. If you can see some processes running even after stopping the process it might be that the process didn't stop properly To ...
0 votes

Nginx 1 FastCGI sent in stderr: “Primary script unknown”

Annother reason can be a missing semicolon (;) after the server_name server_name domainurl.com root /var/www/current/public; which leads to a warning but no error!
  • 133
0 votes
Accepted

NGINX Reverse proxy acme-challenge http to 404

Good morning, After a lot of trying i manage to access to http. Yes! Thanks Richard, Here is the correct conf file: upstream [MySite].com { server "[MySite].com"; } server { ...
  • 1
0 votes

Can I manually give mime types?

Most of the default mime types should be available in /etc/nginx/mime.types file, you can keep whatever required. Passing manually one-by-one may be problematic for you as keeping desired type in this ...
  • 2,401
0 votes

Wordpress Website is Broken When Migrating to NGINX

server { ... #add_header Content-Security-Policy "default-src 'self'; script-src 'self';"; ... } Is this what you were talking about? I was having a similar problem. Not all of the ...
  • 1
1 vote
Accepted

Is there a way to include the request port number in NGINX access.log?

nginx variables documentation on variables shows that $server_port variable contains the server side port for the request. nginx log module documentation documents log_format and access_log directives....
0 votes

nginx: [emerg] "stream" directive is not allowed here

I came across the same error with a default nginx Docker image, I tried to solve it with a small change to the DockerFile: COPY docker/ngnix/ngnix.conf /tmp/docker.nginx COPY docker/ngnix/stream.conf /...
0 votes

Share cache between multiple location blocks

You can modify the cache key used by nginx with proxy_cache_key directive. A warning: You need to understand the caching system in detailed level before adjusting the key, because incorrect settings ...
0 votes
Accepted

When debugging NGINX configuration files, is there a way to print log messages

Request processing internals can be seen in nginx debug log. How to actually enable debug logging depends on the version and distribution you are using. With nginx.org built Debian packages, one needs ...
1 vote

Nginx location matching with regex year/month/day/*

This is a bit niche, but I thought it might help someone and it was too long to comment: ## noindex date archives ## location ~ "^(.*)/[0-9]{4}/([0-9]{2}/)?([0-9]{2}/)?$" { try_files $...
1 vote
Accepted

"/robots.txt" is outside location "\.php$"?

The Nginx configuration part you presented is syntactically incorrect (it's incomplete). Please check all your opening braces have the corresponding close braces. The problem, as I see it, is linked ...
0 votes

nginx not logging any error, no starting

For other guys like me: My problem was on the nginx.pid file. The process was not running, but the file existed, and this prevented to run it. Deleting the file (in my case, /var/run/nginx.pid ), ...
1 vote
Accepted

How to reuse Nginx directives in common

You can move all of the common statements from the location context into the server context. See this document for details. You have an identical set of add_header statements in your location blocks, ...
1 vote
Accepted

NGINX: Location matches assests

have you tried anchoring your regex? location ~ "^/web" {
  • 166

Top 50 recent answers are included