w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Where is my nginx being configured? Changing nginx.conf still brings me to the 'Welcome to nginx' page
when you rewrited the nginx.conf in the folder of source code of nginx and installed it firstly, it will be copied to /usr/local/nginx/conf/nginx.conf (without specially modification of the configure in the folder of source code). But when you do this secondly, the nginx.conf in the folder of source code will be copied to /usr/local/nginx/conf/nginx.conf.defualt,and it usually don't work unless you use nginx -c /usr/local/nginx/conf/nginx.conf.defualt to assign its configure file evertime. There is a line NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" in your script above,which indicates the configure file clearly. To handle this, I suggest rewrite /usr/local/nginx/conf/nginx.conf (not the one in the folder of source code) instead.

Categories : Nginx

nginx.conf for url routing
You might want to try something like this, works like a charm for me: location / { try_files $uri $uri/ @rules; } location @rules { rewrite ^/(.*)$ /index.php?param=$1; } This looks for the location at / which is your web root. All of your web accessible files are found in this directory. If a file exists, it'll take you to that file. If not, then it'll throw you into the @rules block. You can use regexp matching to vary your url formatting. But in short, the (.*) matches any string in your url and takes you to your index. I modified what you had written slightly to feed the original input in to index.php as a parameter. If you don't do this, your script won't have any info about how to route the request. For example, then going to /blablabla will mask the url but pull u

Categories : PHP

Nginx and Cakephp .conf file
Have you tried this? http://book.cakephp.org/2.0/en/installation/url-rewriting.html#pretty-urls-on-nginx If not try my config files. cakephp2-rewrite-rules.conf if (-f $request_filename) { break; } if (!-f $request_filename) { rewrite ^/(.+)$ /index.php?url=$1 last; break; } cake2app.conf location / { index index.html index.htm index.php; allow all; include cakephp2-rewrite-rules.conf; } include php-fastcgi.conf; vhosts.conf server { root /foo/bar; listen vhost:80; server_name vhost; include vhost/cake2app.conf; } Include the vhosts.conf in your nginx.conf in the http section. include vhost/vhosts.conf;

Categories : Cakephp

Default nginx conf file
I guess, first vhost would be used. If you use including virtual hosts (/etc/nginx/sites-enabled/*) the hosts would be included in alphabetical order. So, if you have hosts "a", "b" and "c", first of them will be "a".

Categories : Nginx

Restarting nginx: nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable
Passenger takes what you set in the file nginx.conf by passenger_ruby, for example: passenger_root /home/dev/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.5; passenger_ruby /home/dev/.rvm/wrappers/ruby-1.9.3-p448/ruby;

Categories : Ruby

Can a server run Nginx for some sites and Apache Nginx Reverse Proxy for others?
server { server_name example.com; location / { # assuming apache is on port 81 for example proxy_pass http://127.0.0.1:81; # to make apache detect the host header proxy_set_header Host $host; } # if you have assets folders, you can let nginx serve them directly, # instead of passing them to apache location /images { # or /css or /js .. etc try_files $uri =404; } } Note: in the case of assets, sometimes some sites serve assets through rewrites, or even handled by the application it self, you can pass it to apache by adding that in the assets location as a fallback like this location /images { try_files $uri @apache; } location @apache { proxy_pass http://127.0.0.1:81; } In apache you create a virtual host <Virtua

Categories : Apache

Nginx location behave with and without location regex
I'd suggest excluding the assets from the rewrite, you can do that by adding a new location, something like this location /(css|js|images) { root /var/www/www.my-project.com/web; try_files $uri =404; } And for the location issue, you can match exact locations using = location = /www.my-project.com {

Categories : Nginx

Merging two location blocks in nginx
Thanks to @VBart's advise, for multiple locations using the same proxy config, you can refer http://wiki.nginx.org/Pitfalls "Proxy everything" section, an example: server { server_name example.org; root /var/www/site; location / { try_files $uri $uri/ /index.php; } location ~ .php$ { include fastcgi.conf; fastcgi_pass unix:/tmp/php-fpm.sock; } }

Categories : Nginx

stuck on nginx location directive
The reason is that the location directive matches URI (absolute path of the Request-URI to be more precise), not Host. When you use http://images, your browser sends request like this: GET / HTTP/1.1 Host: images Notice that request URI is /.

Categories : Nginx

nginx location outside document root
Try this: location ~ ^/$ { root /var/www/home; } location ~ ^(?!/$) { root /var/www; } or this: location / { root /var/www; rewrite ^/$ /home/ break; }

Categories : Nginx

nginx location index directive not working
If you explicitly request /index.html, is it served? If not, you might want to add an explicit root /path/to/root; to your server {} block. Also verify that index.html has the correct permissions. This will help with troubleshooting: It will force a 404 if the root index.html is not found. If that happens, at least you can check the logs to see were it was looking: location = / { index index.html; } Also, be sure to do nginx -s reload when changing the config.

Categories : Nginx

location directives confusion in nginx configuration
One of the obvious issues with your configuration is that alias must be used rather than root location /test/ { alias /home/test/; } because, root makes nginx to search for /home/test/test as per your config.

Categories : Nginx

nginx, exclude single file from location
You're going to kick yourself when you see the answer. What I want to do here is to exclude one single file called piwik.php as it should receive special treatment in a separate location. Ok, you should set that path as a separate location before your default one. e.g. location ~ ^/stats/piwik.php$ { allow 127.0.0.1; deny all; fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_read_timeout 150; fastcgi_index index.php; include fastcgi_params; } location ~ .php$ { fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_read_timeout 150; fastcgi_index index.php; include fastcgi_params; } As those are both regular expression location blocks, the one listed

Categories : Nginx

How do I make nginx proxy some urls on a domain to one location and the rest to somewhere else
You can refer to "rewrite" and "proxy_pass" directive in nginx manual and this can be solved easily: location ~* "^/$|^/(a|b|c).*?$" { rewrite "^/(.*)$" /site/$1 break; proxy_pass http://127.0.0.1:8001; ......; // to add any commands you need break; } location / { proxy_pass http://127.0.0.1:8002; ......; // to add any commands you need break; } Because no rewrite directive wrote in server block, Nginx start to match url in location phase. If is is caught by one location (here using the 1st one as example), then enter into rewrite loop. "break" in the end of rewrite means jump out the rewrite loop. Then start dealing with other directives in this location ,here proxy_pass will be dealt with. General process in this case would be: location match --> rew

Categories : Nginx

Nginx - configure location regex for all static file in sub alias
try to add rewrite directive in sub location. Just like this: location /site1 { location ~* .(jpg|jpeg|gif|png|css|js|ico|xml|rss|txt)$ { rewrite "^/site1/(.*)$" /$1 break; root /path/to/anothersite1; } proxy_pass apache:8080; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; }

Categories : File

Websocket location mismatch when Safari 5.0 connects via nginx https proxy
Nginx websocket proxy only works for RFC6455 compliant handshakes. The older draft 75/76 handshakes, found in Safari 5 and old versions of chrome can't be proxied through nginx. Some more details here: Nginx: Reverse proxying WebSocket Draft 76

Categories : Nginx

How to limit max file size for upload in nginx for special location with fastcgi
Is the URI really and exactly http(s)://example.com/account/personal_info/documents/ in your browser? If so, be more specific in your configuration to make sure nginx applies the correct location block. location = /account/personal_info/documents/ { # ... }

Categories : Nginx

Modify the location of php-fpm.conf and php-fpm.d/*.conf?
Certainly, all you have to do is pass the --fpm-config option when starting up FPM /usr/local/sbin/php-fpm --fpm-config <file> You can also specify a specific php.ini path by /usr/local/sbin/php-fpm -c <path> I have mine located in /usr/local/etc/ where I also keep my PEAR and other PHP configurations.

Categories : Misc

nginx + passenger + rails: do I need to start the rails server or just start nginx?
Set nginx to forward to my rails server using this https://gist.github.com/jeffrafter/1229497 worker_processes 1; error_log /usr/local/var/log/nginx.error.log; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream dev { server 127.0.0.1:3000; } server { listen 80; # You could put a server_name directive here (or multiple) if # you have not setup wildcard DNS for *.dev domains # See http://jessedearing.com/nodes/9-setting-up-wildcard-subdomains-on-os-x-10-6 # If we choose a root, then we can't switch things around easily # Using /dev/null means that static assets are served through

Categories : Ruby On Rails

Apache CONF: How to add outside directories without showing the location in source
For Apache, you are looking for either Alias or AliasMatch. For PHP, you are looking for include_path

Categories : PHP

htaccess to nginx (help)
Please try the following: server { listen 80; server_name www.website.com; return 301 $scheme://website.com; } server { listen 80; server_name website.com; root /path/to/root; location / { try_files $uri @rewrite; } location @rewrite { rewrite ^/([a-z]+)/?([0-9a-zA-Z]*)/?.*$ /index.php?a=$1&q=$2 last; } }

Categories : Apache

Nginx add sites
well if you're going to use only 1 IP, then it's 1 server block ( 1 virtual host ) server { server_name [domain name or ip]; index index.html; # or php or whatever location /foo { root /var/www/foo/public_html; try_files $uri $uri/; } location /bar { root /srv/www/bar/public_html; try_files $uri $uri/; } } You haven't mentioned what kind of application this is, so it probably need some changes depending if its a php site or rails or any thing else, this would work for static content only like html and images.

Categories : Nginx

How to use nginx proxy_pass
Try the nginx HttpRewriteModule you dont need a proxy for these(tho). it follows this format: rewrite regex replacement flag | | | | rewrite ^/ http://www.example.com/image/file.aspx?img=1 permanent; Then: location / { rewrite ^/ http://www.example.com/image/file.aspx?img=1 permanent; }

Categories : Node Js

Nginx and Unicorn Set up Not sure what I am doing
I've never used knife... It might be worth checking out this this blog post about setting up Capistrano, Nginx, and Unicorn - I've always found Capistrano to be a good deployment app (and there's lots of support for it, especially on SO). On Heroku, you don't deploy as you would with Capistrano or any other deployment utility - you simply push to a branch on your Heroku server. See: https://devcenter.heroku.com/articles/git for how to deploy on Heroku using Git.

Categories : Ruby On Rails

Git on server with nginx
You need a web frontend for git. Have a look at https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools#Web_Interfaces for an overview

Categories : GIT

When do I need to restart nginx
Probably only when you change its configuration, if you are referring to when your django code changes you have to restart the uwsgi server, usually "touch"ing the wsgi.py file is enough to instruct the uwsgi server. Changes in static files don't require the uwsgi restart (because you usually serve them directly with nginx), and if you don't use cached template loaders, but only the default filesystem loader, you don't require the restart when changing a template either. Note that the cached template loader is usually suggested in production.

Categories : Django

Regex for Nginx
The way you written it means that the / is the one that could appear multiple times, ie /home///////share, to fix it write soemthing like location ~ /home/[^/]+/share { }

Categories : Regex

Upgrading Nginx 1.1.9 to 1.4.x
This is what test environments or virtual machines are made for. Your question is quite general and hard to answer this way. Try it out in a test setup. If you don't have that option, read the Changelog. From my experience, I haven't encountered backwards compatibility issues with configurations since 1.0 (before that even, but that's when officially configuration syntax should be considered stable). That's not to say there aren't any.

Categories : Ubuntu

Redirecting to SSL using nginx
In order to use regular expressions for matching locations, you need to prefix the expression with either ~ or ~*: if ($server_port = 80) { location ~ (en|fr)/shop { rewrite ^ https://$host$request_uri permanent; } } From the documentation: To use regular expressions, you must use a prefix: "~" for case sensitive matching "~*" for case insensitive matching Since nginx does't allow location blocks to be nested inside of if blocks, try the following configuration: if ($server_port = 80) { rewrite ^/(en|fr)/shop https://$host$request_uri permanent; }

Categories : Nginx

nginx and ssl certificate
This is the .cer file, the .key is the key you used to produce this .cer file, try to remember how you got this .cer file, you probably generated a key file on your device, then created a certificate signing request out of it .csr and then uploaded it to get this certificate correct ? you should already have the key file.

Categories : Ssl

PHP htaccess to nginx
@Harinder: There must be some RewriteCond based on which you're applying this RewiteRule The reason why i am saying this is that, according to your RewriteRule RewriteRule ^(.*)$ /all_drivers.php?id=$1 [QSA] whatever that comes as a request, you are sending it to all_drivers.php. And if this is the desired rule, then all the request, no matter what will be send to this file only. Also it will be nice if you give us the complete .htaccess code segment that you want to be translated. And please check if you have configured php execution block correctly with all the required fastcgi directives as this blank php's output comes in the case if you have not passed SCRIPT_FILENAME fastcgi directive.

Categories : PHP

ToroPHP Router in nginx
This question really belongs on http://serverfault.com, nonetheless: Use try files Rewriting isn't necessary, the desired results can be achieved more efficiently using try_files: server { ... location /api { # try_files $uri $uri/ index.php$uri; try_files $uri $uri/ index.php; } } } Note that it's not necessary to pass the url as an argument to index.php as it's already available as $_SERVER['REQUEST_URI'] (will require trivial modifications to index.php to work).

Categories : Htaccess

X-Sendfile, Rails & Nginx
got it: never use any rails route part in your location directive of nginx. with this one, it works: location / { proxy_set_header X-Sendfile-Type X-Accel-Redirect; # Maps a real path to the internal location proxy_set_header X-Accel-Mapping /var/www/cube_storage/uploads/=/downloads; } # end of location app location /downloads { alias /var/www/cube_storage/uploads/; internal; }

Categories : Ruby On Rails

I'm trying to rewrite a sef url into a plain url using nginx
you probably need to add a break at the end of the line rewrite ^/tools/app/(.*)$ /tools/app?action=$1 break;

Categories : PHP

Nginx configuration for trinidad-gem
just google for proxy-ing with nginx - it's likely the same is with other Ruby servers e.g. server { listen sample.com:80; server_name sample.com; root /home/trinidad/rails_app/current/; location / { proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:3000/; } } in Trinidad's configuration you might want to bind to 127.0.0.1 (just add address: 127.0.0.1)

Categories : Ruby On Rails

How to enable xdebug with nginx?
Just in case there's someone reading this... I got it! The problem was nginx's configuration. I had just copied a template from somewhere, but now I read a little more and found out that my particular config was much simpler: location / { root /var/www/bresson/web/; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/dispatch.php; fastcgi_pass unix:/var/run/php5-fpm.sock; } In my case, every request has to be forwarded to my front-controller (which then analyzes the URI), so it was really simple.

Categories : Nginx

NGINX AddHandler equivalent?
if your conf looks like: location ~ .php { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9001; } then you would do this: if your conf looks like: location ~ .(php|ws) { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9001; } not the change from php to (php|ws)

Categories : Nginx

Nginx Vhost Bandwidth?
You could try the Munin Byprojects for that! It does exactly what you described.

Categories : Nginx

Nginx SSL on single subdomain instead of many
Without Server Name Indication, a server serving HTTPS content doesn't know what the domain name being requested is (as the Host header is itself encrypted). Thus, all requests to that IP, regardless of domain name, get the default SSL virtual host.

Categories : Ssl

Separate Nginx Rewrites
Ok since you said it works let me explain what you did, I'll quote them from the wiki page: First the flag you used which is break break: completes processing of current rewrite directives and non-rewrite processing continues within the current location block only. by adding the keyword break to any rewrite rule, it tells nginx to stop the rewriting, so even if it matches another location which has a rewrite, it wont run it, that's why it didn't execute the rewrites inside the location location / { .. } Another keyword is last, last: completes processing of current rewrite directives and restarts the process (including rewriting) with a search for a match on the URI from all available locations. This one which tells nginx to stop the rewriting and restart rewriting again wi

Categories : Nginx



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.