Tag Info

New answers tagged

0

I get that you want to rewrite faq to faq.php and if that is the case, all you need to do is: rewrite ^/faq$ faq.php last; And that's it.


1

The reason for alpha.draser.co.uk hitting SSL is this definition: add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"; This tells browser always to use HTTPS to connect to any subdomain of draser.co.uk. You have received this setting from the server on the first occasion when you have requested https://draser.co.uk. This is a ...


0

Make sure /srv/www/app/shared/sockets/unicorn.sock has correct rights for the user nginx's worker processes are running with (www-data in your case).


0

From nginx's documentation : If the proxy_pass directive is specified with a URI, then when a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the directive. So here this means if you hit http://<domain>/cfbrokerlogs/foo then it will be forwarded as ...


0

And the answer is: server { # <...> rewrite ^/stuff-(.*) /stuff/$1 permanent; rewrite ^/stuff/(.*) /stuff-$1; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header HOST $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:2368; proxy_redirect off; } }


0

how about to catch 401 header: location @checkauth { auth_basic "Restricted"; auth_basic_user_file htpasswd; } location / { if ($http_authorization = "") { #return custom code error_page 490 = @checkauth; return 490; } auth_basic "Restricted"; auth_basic_user_file htpasswd; error_page 401 = @rewrite; }


0

This is a common misunderstanding in nginx configuration. Try this: location /piwik/ { alias /var/www/xyz/piwik; }


0

You need to make sure the links are in correct format in your software also. nginx cannot rewrite links in the pages themselves, you need to handle those other way. However, making nginx show /stuff-life when accessing /stuff/life can be done like this: location ~ /stuff/(?<part>.+)$ { rewrite ^ /stuff-$part last; }


0

The issue here is that rewrite directive destination part is always relative to the root directory. So, assuming your setup is like this: root directory is /var/www/domains/podziemieopowiadan-old Forum scripts are at /var/www/domains/podziemieopowiadan-old/forum Then your rewrite needs to look like this: rewrite ^/forum/((?i)sitemap-([^./]+)\.xml)$ ...


1

I cannot write comments, but I believe the reason you need the trailing slash is because nginx thinks "/nagios" refers to one exact path, for example you might forward "/site.css" to "/css.php?file=site", whereas with the slash on the end, it refers to a whole directory and subdirectories, not just the exact path specified. In this case, you want everything ...


0

It turns out that the proxy_pass location directivelocation /nagios {} in the upstream server had to be changed into location /nagios/ {}. I do not understand why, but the reverse proxy now works fine.


5

Define a default server if you don't explicitly define a default server, nginx will implicitly use the first-found server. so, just create a server block to block unknown hosts: server { listen 80 default_server; return 444; } (no it's not necessary to add a server_name - since it will never be a match).


0

The issue was caused by upgrading CentOS from 6.5 to 6.6 and how SElinux allows content type through. With this upgrade SElinux by default only allows httpd_t content through (similar to how they treat apache), and because I store all my webcontent in /srv/www/ these user created folders did not have content label set automatically by the system. To check ...


1

You define a passive port range of 50000-51000 in the vsftpd.conf but only explicitly open a single port 51000 in your firewall configuration. Since you're using TLS to secure the connection the normal netfilter FTP helper module can't dynamically open the related passive port. Solution: open the correct port range. sudo firewall-cmd --permanent ...


0

First you should rule out a SELinux problem. Search /var/log/audit/audit.log for ftp entries: audit2why < /var/log/audit/audit.log Check the vsftpd logs for any errors. If nothing is working use strace on vfstp and try to figure out where is failing. Which SELinux context is set for /usr/share/nginx/html/ file? Run the following command to see this: ...


0

use php-fpm pm = ondemand pm.max_requests = 10000 and create some kind of swap https://www.varnish-software.com/static/book/Tuning.html#storage-backends these days there is no problem to get a bigger server/vps.


2

Magento is a heavy piece of software. What makes you think your server would NOT scream in agony during your 500 users performance test? Of course serving static content is fast, but parsing all that black magic PHP that Magento contains... well, it's a heavy duty job for your server. The PHP op-code cache does not mean that your PHP would be as fast as ...


1

It depends. I'm assuming, that nginx serves (and proxies) ports 80 and 443 to JBoss. For this alone, setting um SSL in nginx is sufficient. If JBoss needs to serve a different port via SSL directly, without nginx proxying, to handle your application needs, (e.g. 8443) then you need to setup SSL in JBoss too.


0

Yes you can do it with Nginx. Use FastCGI cache for it. Here is one of many tutorials how to do it: https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps


0

chmod ogw file sets permission on file for owner, group and world, each being the sum of read(4), write(2), execute(1), if wanted no proper access to read write drwxr-x--x brian nobody website1 nginx is reading only, so you have to let him into! cd /srv/ find . -type d -exec chmod 755 {} \;


0

It looks like you have a lot of TCP connections that are not terminating correctly. Basically, the CLOSE_WAIT connections means the server has recieved a FIN packet, and is now waiting for either the maximum segment lifetime or the server to tell the network stack to close the socket. The FIN_WAIT messages are due to the fact that the "server" sent a FIN ...


2

Without the CNAME, you would need an A record for the www-subdomain instead, otherwise DNS resolution for www.example.com won't work and the request won't reach your server. You will also need the ServerAlias, because even when using CNAME, the host header in the HTTP request won't change, so it will still be www.example.com and you need to tell ...


1

I had the same problem on CentOS 7, and I did what you did. I solved it by setting globally SELinux to permissive mode. # setenforce 0 You commented that you disabled SELinux, maybe you can check the logs to find out if it's really disabled sudo cat /var/log/audit/audit.log | grep -i nginx I've found my solution here: NGINX: SELinux Changes...


1

ANSWER: I made the mistake of not removing the wildcard "*" from the nginx.conf file path statement that points to the directory (or in this case with the wildcard DIRECTORIES) used for the site configurations...~thus the error(s) I was given at reload time pointing to a line item error was actually in one of the other conf files and NOT my "default" conf ...


0

Here's what I ended up doing instead: server { server_name "~^port(?P<forwarded_port>9\d{3})\.example\.com$"; location / { proxy_pass http://127.0.0.1:$forwarded_port; } } That way, you can simply connect to http://port9034.example.com;


1

^/author/(*)$ means that it starts with /author/. The URLs you want to rewrite don't start with /author/. You need something like this: rewrite ^/.*/author/(.*)$ http://example.com/profile/$1 last; But I think this is better and probably more robust: rewrite /author/([^/]+)/?$ http://example.com/profile/$1 last;


0

Just make a script. Sure an elegant solution built into nginx would be nice... but let's not forget the tools *nix affords us: #!/bin/bash for i in /etc/nginx/conf.d/*; do sed -i 's/server_name example.com www.example.com;/server_name other.example.com;/g' "$i"; done ... You may have to escape those semicolons.. Not sure...


1

If you have no default_server defined, nginx will use the first server it finds as the default server, so this behavior is standard and expected. If you don't want that, define a default-server that is to be used and which might just return some error if you want this.


1

Just disable PHP Notice in php.ini / fpm conf error_reporting = E_ALL & ~E_NOTICE It won't cause any issues.


-1

try location /foo { proxy_pass http://localhost:3200/; .... or location ^~ /foo { proxy_pass http://localhost:3200/; ....


1

Yes, either a proxy_pass or rewrite rule would work for that.


0

You could try doing something like this: error_page 401 /401.html; error_page 444 /444.html; location = /401.html { internal; access_log /var/log/nginx/401.log; } location = /444.html { internal; access_log /var/log/nginx/444.log; } More about error_page: http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page


0

This may not be the cleanest or wisest solution but I would expect the following to work given your listed use cases... # Default location location / { try_files $uri $uri/ $uri/index.php?q=$uri&$args; } Depending on your implementation you MAY need an extra /index.php?q=$uri&$args The downside is that it will likely break any projects that ...


0

You can't. Sorry. But if what you seek is to add scalability, i.e. to be able to add new projects without editing the nginx config, then you can implement a slightly different approach. Create a folder in the same directory with your nginx config. For the sake of this example, I'll take the name project_configs. My nginx.conf is located in ...


0

This can be achieved by using Amazon SDK ( I am almost done with it, will put it on github ), utilizing the SNS, EC2 and Autoscaling service. I have followed the below steps to achieve this: Enable HTTP notification and subscribed my webserver. Added a lifecycle-hook with heartbeat of 1 min (to wait for 1 min before terminating) to my autoscaling group ...


2

Modify your try_files line to look like the following: try_files $uri $uri.html /index.html =404; The reason you are seeing a loop is that try_files will force a redirect to the last entry if no valid location is found during the search. Further reading and reference: http://wiki.nginx.org/HttpCoreModule#try_files


1

Try adding the root and index lines outside the "location" block: ... access_log /var/log/nginx/access.log; root /data/www; index test.html; location / { ...


0

You have completely wrong approach. Please do read more about Nginx proxy caching http://nginx.org/en/docs/http/ngx_http_proxy_module.html This can also be usefull: How to set up Nginx as a caching reverse proxy?


1

Is it safe to assume that the fault lies somewhere in my server configuration and has nothing to do with the code itself? No. The problem is most likely your code. Or your database. Or the interaction between the two.


0

limit_req_zone limits requests to the server to one request per sec in limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;, that includes PHP and static files requests depending on where you placed the limit_req zone=one; statement. Try to limit only PHP requests (inside location ~ \.php$ {) and leave static content unrestricted.


0

Personally I would rate limit only for specific TCP packets (syn flood, scans of various types, etc) with iptables and use nginx to rate limit HTTP requests per time interval behind this. Keep in mind that browsers open multiple TCP connections for a single actual user so rate limiting to 50 connections per minute once the burst is reached is dramatically ...


2

nginx can be considered a "reverse" proxy (due to its "upstream servers" functionality).... when in this role, it is effectively a "load balancer". a "normal" proxy, such as squid http proxy, socks, etc... fetches content on end user behalf, and sits in front of end users, making tcp/ip calls out to the internet web servers and ideally caching content. ...


1

Nginx is a web server... so it is not being used to replace squid very frequently ;) (Nginx proxy mode is different, it is used basically to transfer http requests to another server)


3

Cloudflare has these ip ranges, you can use nginx built-in real_ip module and setup headers properly https://www.cloudflare.com/ips set_real_ip_from 204.93.240.0/24; real_ip_header CF-Connecting-IP; https://support.cloudflare.com/hc/en-us/articles/200170706-Does-CloudFlare-have-an-IP-module-for-Nginx-


-3

Use for example: http://nontroppo.org/tools/gziptest/ Enter your site url press "start testing". Sample output: HTTP/1.1 200 OK Server: nginx Date: Sat, 17 Jan 2015 18:44:25 GMT Content-Type: text/html; charset=ISO-8859-1


-1

Your backend responds with < Cache-Control: max-age=2592000, public, must-revalidate, proxy-revalidate < Expires: Sat, 14 Feb 2015 19:33:58 GMT So does the original answer, and this overrides the proxy_cache_valid setting: Parameters of caching can also be set directly in the response header. This has higher priority than setting of caching time ...


0

The deny command works by sending a 403 header indicating that the content is forbidden. In this scenario the redirect is occurring because you are rewriting the header to 301 right after the deny. So any other location context you create will be denied unless you explicitly return a different header.


0

Your getting the default NGINX page, because your server_name tells NGINX that your configuration directory is not for localhost, therefore, NGINX uses the default installation directory to serve the localhost pages. Test the following: server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root ...


0

Setup your AWS ELB mapping ELB:80 to instance:80 and ELB:443 to instance:1443. Bind nginx to listen on port 80 and 1443. Forward requests arriving at port 80 to port 443. NGINX Setup server { listen 80; server_name www.example.org; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 1443; ...


1

Setup your AWS ELB mapping ELB:80 to instance:80 and ELB:443 to instance:1443. Bind nginx to listen on port 80 and 1443. Forward requests arriving at port 80 to port 443. NGINX Setup server { listen 80; server_name www.example.org; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 1443; ...



Top 50 recent answers are included