w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Serving multiple node apps with nginx on same domain
Just found out what the problem was. Though my nginx configs were correct, I had not added my desired subdomain to my domain name provider (namecheap). I added my subdomain on namecheap, and everything is working correctly now.

Categories : Node Js

Nginx config for serving snapshots to the Google bot
Ok first let me explain why google uses ?_escaped_fragment_, This is used for websites that rely on ajax, and mark their page with hashes, like for example if you have http://example.com/gallery/#!image1 and each time the user changes to the next image you update the hash to image2, image3, but if the user goes directly to http://example.com/gallery/#!image50 your javascript uses that hash to load the 50th image directly instead of image1 ( servers can't see the hash part, only javascript can ). So google uses this _excaped_fragment_ to tell the server which page it's trying to cache. For more explanation use this link As for why you get a 404 error, I think because you used a $1 without using a capturing block, The right rule would be something like this location / { if ($args ~ "_

Categories : Angularjs

Nginx isn't serving static rails asset files
Figured it out. I wasn't looking at the nginx error log before for some reason. Once I looked there I could see that those assets were getting "permission denied" error for them. I tracked down this problem and had to make sure every directory from the root to the location of the asset files had: chmod +x on it.

Categories : Ruby On Rails

Nginx as reverse-proxy: serving files without extension
The problem is, that you need something to identify the files without any extension. A sub-directory or something that’s always present within the request. Your regular expression only matched for requests that start end end with a dot (e.g. http://example.com/.). The following server configuration assumes that all URLs start with storage, as this would be the only possibility to identify those files. Please note that I’m using the try_files directive to rewrite the internal path where nginx should look for the file. The root directive is not meant for what you want to achieve. And last but not least, you should always nest location blocks with regular expressions. There is no limit in the nesting level. nginx will create some kind of tree data structure to search for the best matchi

Categories : Nginx

Serving static files with Nginx + Gunicorn + Django
You need to create an nginx location block that matches the location of your django STATIC_URL. As you have it configured, nginx is also forwarding requests for static assets to your django application. I'm guessing you are seeing the 404 errors in your django application log? You want nginx to handle these requests, not django. location /static { alias /home/tunde/django-projects/mumu/STATIC/; } Be sure to run the django admin command collectstatic to make sure all the static assets get copied to the STATIC_ROOT directory.

Categories : Django

Nginx serving non-secure resources on https domain
maybe cause this is how they are called, if you need to serve every thing as https, i would create an empty server that listens on 80 and redirect to https server { # listen 80; delete this part listen 443 ssl; # the rest of the config } # add this server server { listen 80; server_name example.com; location / # or a more specific location '~ .(jpg|css|js|jpeg|png|gif)' { return https://example.com$request_uri; } } or just fix the css location, it might be an absolute URL with http

Categories : Magento

Serving either a static or dynamic file based on a query variable using nginx
I think that you need something like this: location /thumbs/ { if ($arg_nocache) { rewrite ^(.*)$ /thumbs/index.php?r=$uri&$query_string break; } try_files $uri /thumbs/index.php?r=$uri&$query_string; }

Categories : PHP

serving static files with nginx on diffent machine and gunicorn on a diffrent one for a django production
Please can any one advice me the right way to do this in a production environment. Use a network attached storage (NAS) device that is mounted on both machines. This is how you would do it the right way in production. You could do all sorts of other workarounds - like rsync, nfs, etc. however the most reliable way to have this working is with a proper NAS.

Categories : Django

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

SVN: checkout from multiple URLs to the current working directory under same path?
You can get needed result, while and if COMMON and HOST files are stored in the same repository You use SVN 1.6 or later (I'll recommend to start using 1.8) Solution is file-based externals: re-read carefully "Externals Definitions" in SVN-Book, starting from words Subversion 1.6 also introduced support for external definitions for files. File externals are configured just like externals for directories and appear as a versioned file in the working copy. I.e you files in common/nagios/etc + common/nagios/objects will be maintained files, files inside HOST-tree - externals to files in COMMON (if all files have unique names). Checkouted HOST-tree will have all files in Working Copy (if externals wasn't disabled on checkout)

Categories : Svn

Serving up a file not located within the IIS's virtual directory
Without knowing what you are trying to achieve, let me start by saying that this is not advised. The web application is supposed to work inside a sandbox when it comes to IO access of the host environment. However things can change if you are in a shared hosting environment. What's preventing you from copying these images to a subfolder within your virtual directory? Another option is to create a separate virtual directory for this outside folder and access it just as another resource in the web. Again, you might get better response if you describe what you are trying to do in a bit more detail.

Categories : C#

Golang template serving css on different directory levels
Didn't tested it, so I'm not really sure, but what about changing <link href="css/style.css" rel="stylesheet"> to <link href="/css/style.css" rel="stylesheet"> ?

Categories : HTML

Modifying the path for serving static resources
Have you seen the class org.springframework.web.servlet.DispatcherServlet? In the web.xml: <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> And in the dispatcher-servlet.xml: <mvc:resources mapping="/v1/client/*.html" location="/client/pages/" /> <mvc:resources mapping="/v1/client/*.js" location="/client/js/" /> <mvc:resources mapping="/v1/client/*.css" location="/client/css/" /> If you want to use a base tag, see relative paths.

Categories : Java

Serving static files( including HTML files). Nginx vs Node.js. Which one is more scalable?
Both Node.js and Nginx are asynchronous (non-blocking) servers. Nginx is definitely more well suited for serving your static files. However, depending on your use case, the difference may not be worth the added administration overhead. You would really have to be running a significant amount of traffic before you would notice the difference.

Categories : HTML

PowerShell script to copy two files from a static location to a location with two variables in the in path
First of all create CSV with structure like below (users.csv): Name,Sip login1,login1@gmail.com The run following statement: Import-Csv C:PATH_TO_CSVusers.csv | foreach{cp C:YOUR_PATHYOUR_FILE ("C:Users"+$_.Name+"AppDataLocalMicrosoftCommunicator"+$_.Sip)} Update Script for run for current user: $userName = [Environment]::UserName; $domain = [Environment]::UserDomainName; # Look for a user $Rech = new-object System.DirectoryServices.DirectorySearcher $rc = $Rech.filter = "((sAMAccountName=$userName))" $rc = $Rech.SearchScope = "subtree" $rc = $Rech.PropertiesToLoad.Add("mail"); $rc = $Rech.PropertiesToLoad.Add("msRTCSIP-PrimaryUserAddress"); $theUser = $Rech.FindOne() Write-host "Username is" $userName Write-host "Domain is" $domain if ($theUser -ne $null) { Write-Host "Mail is"

Categories : Powershell

Incorrect path for generated coffee sourcemaps when serving with nodejs
This appears to actually be a bug in the CoffeeScript Grunt task. See: https://github.com/gruntjs/grunt-contrib-coffee/blob/master/tasks/coffee.js#L87 options = _.extend({ generatedFile: path.basename(paths.dest), sourceRoot: mapOptions.sourceRoot, sourceFiles: mapOptions.sourceFiles }, options); Here, if the options object has a "sourceRoot" element, it will override the generated sourceRoot which is created by this function: https://github.com/gruntjs/grunt-contrib-coffee/blob/master/tasks/coffee.js#L130 var createOptionsForFile = function (file, paths) { return { code: grunt.file.read(file), sourceFiles: [path.basename(file)], sourceRoot: appendTrailingSlash(path.relative(paths.destDir, path.dirname(file))) }; }; Which uses the relative path from

Categories : Node Js

Django under IIS (with HeliconZoo) in virtual directory - urls resolver works with path without directory name
Finally, I've found what's wrong with it. Appeared that the reason for described behavior is a setting provided with default web.config file: <add name="django.root" value="%APPL_VIRTUAL_PATH%" /> After I removed it everything started working fine. Here is some info related to django.root variable applied to Apache.

Categories : Django

Python joining current directory and parent directory with os.path.join
You can use normpath, realpath or abspath: import os goal_dir = os.path.join(os.getcwd(), "../../my_dir") print goal_dir # prints C:/here/I/am/../../my_dir print os.path.normpath(goal_dir) # prints C:/here/my_dir print os.path.realpath(goal_dir) # prints C:/here/my_dir print os.path.abspath(goal_dir) # prints C:/here/my_dir

Categories : Python

Directory.Delete(path, true) throws IOException "The directory is not empty"
It appears that info.EnumerateFiles was the issue. I got that idea from this answer. I switched that to info.GetFiles and I was then able to delete the directory after.

Categories : C#

How to resolve a relative directory path to canonical path in MATLAB/Octave
The simplest way I know to convert a path to its canonical form is using cd command: oPath = cd(cd(iPath)); Note that this would fail if the path does not exist on your file system.

Categories : Matlab

How to make $_SERVER['DOCUMENT_ROOT'] reference to alias directory path and NOT wamp default path?
I think you would be better creating a Virtual host for each of your projects. HowTo setup Virtual Hosts

Categories : Apache

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

PHP: Does file_exists($path) check sub directory of $path ? how computationally intensive it is?
I'm not sure if you mean does file_exists($path) check subdirectories of path or if it checks subdirectories of the current working directory for path. In either case the answer is no. $path is taken simply as a path and the method confirms whether or not that file/directory exists.

Categories : PHP

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

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

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

Lua's package path in nginx
You want to modify the Lua package.path to search in the directory where you have your source code. For you, that's lua/. You do this with the lua_package_path directive, in the http block (the docs say you can put it in the top level, but when I tried that it didn't work). So for you: http { #the scripts in lua/ need to refer to each other #but the server runs in lua/.. lua_package_path "./lua/?.lua;;"; ... } Now your lua scripts can find each other even though the server runs one directory up.

Categories : Nginx

nginx missing sites-available directory
Well I think nginx by it self doesn't have that in it's setup, but the Ubuntu maintained package does it as a convention to imitate apache setup, you can create it your self if you want. Create /etc/nginx/sites-available and /etc/nginx/sites-enabled and then edit the http block inside /etc/nginx/nginx.conf and add this line include /etc/nginx/sites-enabled/*; of course all the files will be inside sites-available and then you create a symlink for them inside sites-enabled

Categories : Nginx

Nginx change /phpmyadmin directory
I think your problem in the second config is the index inside /phpmyadmin replace it with just index index.php Here's my server's phpmyadmin, but it's configured as a subdomain. server { client_header_timeout 0; server_name phpmyadmin.example.com; root /var/www/phpmyadmin/; #replace this with your phpmyadmin location #like /usr/share/phpmyadmin for example index index.php; access_log /var/log/nginx/phpmyadmin_access_log; error_log /var/log/nginx/phpmyadmin_error_log; location ~* .php$ { try_files $uri =404; fastcgi_index index.php; fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; client_max_body_size 64m; client_body_buffer_size 128k; } location ~* .(jpg|jpe

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

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

Error in path in GlassFish app when using Nginx
The link on your landing page is generated by the upstream app server. Without changing that, you have to tell nginx how to serve that url. One solution could be adding the following location block: location /Calenicon/ { proxy_pass http://localhost:8080; proxy_set_header X-Real-IP $remote_addr; }

Categories : Java

How to protect site path in nginx?
location ^~ /path-to-dir {deny all} or location /path-to-dir { auth_basic "closed site"; auth_basic_user_file /full-path-to-htpasswd; }

Categories : Security

Rails nginx directory index is forbidden
Nginx needs to have read permissions for the file as well as execute permissions for every hierarchical parent directory of the file to chdir to it and also Sometimes, the index directive does not contain the desired directory index.

Categories : Ruby On Rails

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

Setting proper path in Nginx for Symfony2
Well, what are the dots doing there in your path? You can’t have a directory with three dots as name (at least this would be new to me). The error message from nginx is very specific in that regard. That path doesn’t exist. server { listen 80; server_name _; root /home/public_html/web; location / { location ~* ^/dev/symfony_app/(app|app_dev|config).php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/var/run/php-fpm.sock; } } } That should do the trick. The absolute local path to the index file of your Symfony installation has to be /home/public_html/web/dev/symfony_app/index.php. A request to http://example.com/dev/symfony_app will map the above l

Categories : Symfony2

How can I keep multiple gevent servers serving forever?
Start each server loop in its own instance of Python (one console per gevent). I've never understood trying to run multiple servers from one program. You can run the same server many times and use a reverse proxy like nginx to load balance and route accordingly.

Categories : Python



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