w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
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

nginx hanging for subdomain
Probably an issue with the FastCGI handler (are you using php-fpm?) running at 127.0.0.1:9000 - is it running and accepting connections? Debug it by SSHing to that machine and running: curl -vv http://127.0.0.1:9000/ What happens?

Categories : PHP

nginx - two subdomain configuration
The mistake is putting a server block inside a server block, you should close the main server block then open a new one for the sub domains server { server_name example.com; # the rest of the config } server { server_name sub1.example.com; # sub1 config } server { server_name sub2.example.com; # sub2 config }

Categories : Nginx

NGINX: node.js + php on domain + subdomain
Please include any messages you see on response of trying to visit both vhosts. As well make sure you include this setup in your nginx config as well as service nginx reload after changing configurations. In order to proxy nginx to node you have to use upstreams. Here is configuration that might suit your needs: upstream node { server 127.0.0.1:8000; } server { listen 80; server_name myawesomeapp.ru; location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ { access_log off; root /srv/myawesomeapp/static try_files $uri $uri/ =404; expires 365d; } location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host;

Categories : PHP

Nginx for multiple apps with different subdomain
I believe the root directive should be in the location section. I am unsure of the rails directive and passenger_enabled directive but the rest is similar to what I use and works. Might be best to also specify the index script (i have it set to index.php but change as appropriate). Once you have made the changes be sure to restart nginx. server { listen 80; server_name mydomain.co; location / { root /mydomain/current/public; index index.php; } passenger_enabled on; rails_env production; } server { listen 80; server_name testing.mydomain.co; location / { root /mydomain-test/current/public; index index.php; } passenger_enabled on; rails_env test; }

Categories : Ruby On Rails

Nginx - Limit number of letters in subdomain
I can spot a couple of syntax errors in your code: Nginx uses curly braces { } to specify internal directives so when you are using {0,2} it is trying to read that as a directive - you would need to double quote to avoid this; After your $ you should have a { to open up the directive for your location statement. However the biggest problem is that location is not related to subdomains - what you're looking for is server_name in the stage above location. Read more about server names in the documentation. note: this is untested code; I'd try something like the following: server { listen 80; # We require the expression in double quotes so the `{` and `}` aren't passed as directives. # The `w` matches an alphanumeric character and the `{7}` matches at least 7 occurren

Categories : Nginx

Subdomain hosting with Django + Nginx +Gunicorn
"Using the sites framework" is somehow the same as hosting two projects with the same database. If you would use the sites framework you would have seperate instances for each subdomain which share the same code base and data base, but have to differ in one setting in the first place, which is SITE_ID. If you're able to run multiple instances this for sure has some advantages: You don't need additional processing via a middleware You can easily choose different settings for each site, eg. different template paths, use different middleware etc, even customize urls per project if necessary You're doing already some kind of load-balancing, as you're directing requests to seperate instances, also if one site crashes it shouldn't affect the others If you can only run one instance I guess

Categories : Django

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

Remove Subdomain from URL string , keeping the rest of URL (for replacing subdomain)
You can split the domain as: $url = "city1.domain.com.uk/index.php?page=category/238/12"; list($subDomain, $params) = explode('?', $url); list($domain, $sub) = explode('/', $subDomain); $newUrl = $sub . "?" . $params; echo $newUrl; Cheers!

Categories : PHP

Subdomain forward to another subdomain without redirecting
Since the two domains ("test" and "m.test") have different document roots, you're going to need to reverse proxy. The problem here is mod_proxy, the proxy module, may not be loaded by your host, but you'd do something like this: RewriteEngine On RewriteCond %{HTTP_HOST} ^m.test.example.com$ [NC] RewriteRule ^(.*)$ http://test.example.com/$1 [L,P] These rules would be in the /m.test/ folder, the document root of the m.test.example.com subdomain. The P flag tells mod_rewrite to hand the request to mod_proxy to reverse proxy instead of redirecting the browser.

Categories : Apache

Creating a subdomain Auth cookie then redirecting to subdomain loses the cookie in asp.net MVC4
I have good news and bad news. The bad news is-- you can't do it. See here for an explanation. Essentially your server is setting a cookie for a domain it does not contain, so the cookie is rejected. The good news is-- you don't want to do this anyway. Your design violates OWASP 2013 A4 (unsecure and unvalidated direct object reference). In this case you are storing user's access permissions as the domain of the cookie, which a hacker can easily modify. Find a different way to designate subdomain access. There are all kinds of ways to do this. Here is one way that is pretty close to your plan: Store the subdomain in the cookie value itself. Create a secure document container that lists the subdomains to which the user is granted access. You could for example store the subdomain

Categories : Asp Net

How do I get .htaccess to redirect from wildcard subdomain page to wildcard subdomain folder
Add this to the htaccess file in your document root(s): RedirectMatch 301 ^/([^/]+).php$ /$1/ You'll most likely need that trailing slash because if it's redirecting you to a directory, mod_dir will redirect again in order to add the trailing slash. EDIT: To exclude, you'll have to use mod_rewrite: RewriteEngine On RewriteCond %{REQUEST_URI} !index.php RewriteRule ^/?([^/]+).php$ /$1/ [L,R=301]

Categories : PHP

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

.htaccess issue when trying to remove the www from subdomain
You are forgetting to keep the request uri. Use the following code (copied from somewhere; don't have the original source to give credit): <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] </IfModule> Edit: I suppose you have something like the following code in your .htaccess RewriteCond %{HTTP_HOST} ^(.*).calu.info$ RewriteRule ^(.*)$ http://%{HTTP_HOST}%1/$1 This needs to be removed

Categories : Htaccess

issue with subdomain routing in symfony 2.3.2
In routing the first match wins. So you main bundle may be imported before your specific bundle. Either move the my_bundle import to first or set a host: %main_host% to all other imports.

Categories : Symfony2

Give a url a subdomain name without it being a subdomain
you can do this with create sub domain with wild card for this here is the steps create sub domain in your cpanel with "*" resulting this step it creates folder in ftp called "wildcard" and now you can create code in wildcard folder and watch out the premium user

Categories : PHP

forced https on subdomain .htaccess file is sending wordpress admin page to parent domain
Place the following in the .htaccess for the domain # .htaccess WildCard SSL + wordpress + subdomain RewriteEngine on RewriteCond %{HTTP_HOST} ^shop.domain.com$ RewriteCond %{REQUEST_URI} !^/shop/ RewriteRule ^(.*)$ /shop/$1 RewriteCond %{HTTP_HOST} ^shop.domain.com$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(/)?$ shop/index.php [L] # BEGIN WordPress for main domain <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ RewriteRule ^index.php$ - [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress

Categories : Wordpress

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

nginx doens't run php files
I'm no nginx expert(did not start using it yet) but I know that you need to configure nginx and link it to fast cgi to be able to compile the php code see link: http://www.sitepoint.com/setting-up-php-behind-nginx-with-fastcgi/

Categories : PHP

CodeIgniter + Nginx + Other files in /var/www
yes. You have to use virtual hosts, or create server to listen od different ports othrwise how it will server know which location to serve?? unless you mean somethign like localhost/myporject1/ and localhost2/myproject2? then just setup the server to point to root /var/www and adjust path in fastcgi for CI server { listen 80; server_name localhost; root /var/www/; location ~ /. { deny all; } #you codigniter project location /yourcodigniterproject { index index.html index.php; try_files /cache$uri @web; } #your other project (if usign php replicate the top with difrent directives) location /yourotherproject { index index.html index.php;

Categories : PHP

Nginx + PHP, browser tries to download PHP files
Most likely your PHP script does not set a content MIME type and therefore the default_type directive is used. Check your config for default_type application/octet-stream and change it to default_type text/html or make sure your PHP returns a proper content MIME type.

Categories : Bash

How to add headers to only specific files with nginx
Currently we have two options to solve this: Option 1: Duplicated locations: NGINX looks for the best match. (a little better performance) location /post/ { post config stuff; . . . } location ~* ^/post/.*.(css|js|png|gif)$ { post/files.(css|js|png|gif) config stuff; expires max; add_header Pragma public; add_header Cache-Control "public"; } location /user/ { user folder config stuff; . . . } location ~* ^/user/.*.(css|js|png|gif)$ { user/files.(css|js|png|gif) config stuff; . . . } Option 2: Nested locations: Filtered by extension in the inner location blocks location /post/{ ... location ~* .(css|js|png|gif)$ { expires max; add_header Pragma public; add_header Cache-C

Categories : Nginx

Set Nginx expires header for all js and css except some files
Try: location ~* .(js|css)$ { location ~* (file.js|name.css)$ { expires off; } expires 30d; } or location ~* (file.js|name.css)$ { expires off; } location ~* .(js|css)$ { expires 30d; }

Categories : Nginx

Nginx write files into GridFS
No. You should upload to GridFS using your web application that Nginx is serving. For example in Perl there's MongoDB::GridFS.

Categories : Mongodb

Paperclip + S3 + Nginx issue on image upload
I had the same issue sometime ago and it worked for me just to restart my web server. I was using Passenger in my application. I forgot to mention that I created an interpolation with Paperclip method Interpolates, just like that: #config/initializers/paperclip.rb Paperclip.interpolates :class do |attachment, style| attachment.instance.class.model_name.downcase.pluralize end Now the files url at S3 will make use of .../users/..., not .../males/... or .../females/... anymore.

Categories : Ruby

Static files in Nginx, Gunicorn in Django
You got the root and url backwards. Should be: STATIC_ROOT = '/Users/gcarranza/PycharmProjects/clouddemyTest/static/' STATIC_URL = '/static/' And same for media

Categories : Django

How to set site files properly and avoid nginx 403?
The really short answer is to move your clone from /root/ to /var/www. A clone does not care where it lives, but access root's home directory is shielded for good reasons.

Categories : Nginx

Insert GET-parameter into static files with Nginx
Take a look at the http_sub_module Something like this may work: sub_filter '<CALLBACK>' $arg_callback;

Categories : Testing

Managing Nginx FastCGI cache files
From reading http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_path I would note that cache size and contents are managed through following options to fastcgi_cache_path directive: inactive: "Cached data that are not accessed during the time specified by the inactive parameter get removed from the cache regardless of their freshness. By default, inactive is set to 10 minutes." So I would suppose that with default settings all files that were not accessed within last 10 minutes should be removed; max_size: "The special cache manager process monitors the maximum cache size set by the max_size parameter. When this size is exceeded, it removes the least recently used data.". I would guess that you do not have max_size limit set at all. So with large number of objects

Categories : Nginx

Can't figure out how to serve static files with Nginx
You're missing a http block. Your upstream and server block need to be wrapped by an http block. Your final file would look like this. EDIT: I've also added in some defaults that are usually supplied with /etc/nginx/nginx.conf worker_process = 1; events { worker_connections 1024; } http { include mime.types.default; # server_tokens off; # Optional # sendfile on; # Optional # keepalive_timeout 100;# Optional # tcp_nodelay on; # Optional # nginx.conf upstream django { # connect to this socket # server unix:///tmp/uwsgi.sock; # for a file socket server 127.0.0.1:8000; # for a web port socket was 8001 } server { # the port y

Categories : Nginx

Nginx: Serve Files from different Root Locations
First of all I advice you to take a backup of your conf file before starting all this. Anyway, you were doing great at first, but then you added stuff that didn't need to be added, like for example try_files $uri $uri/ @handler; This line doesn't really need to be split into two, you could just merge the rewrite into it try_files $uri $uri/ /index.php; But then it makes me wonder how it's working without the $request_uri, so if doesn't work i would try using this line instead: try_files $uri $uri/ /index.php$request_uri; Now this block i don't really understand what it's supposed to do location ~.php/ { rewrite ^(.*.php)/ $1 last; } I'd say it's safe to remove it entirely, cause it seems to be rewriting the request to the same thing it was. And inside the php conf, the w

Categories : Codeigniter

Nginx returns 404 on cached html files
Try this: location @rewrite { # Some modules enforce no slash (/) at the end of the URL # Else this rewrite block wouldn't be needed (GlobalRedirect) rewrite ^/(.*).html$ /index.php?s=$1 last; }

Categories : Nginx

Wrong word boundaries in nginx files with vim
Your 'iskeyword' is changed in that syntax script on line 8, 9 and 10: setlocal iskeyword+=. setlocal iskeyword+=/ setlocal iskeyword+=: Comment out these three lines to fix your issue.

Categories : Vim

How to serve static files in forum subfolder on nginx?
Replace if ($request_uri ~* "^/qa/") { rewrite ^/qa/(.*)$ /qa/index.php?qa-rewrite=$1 last; } with location ~ /qa/(.*)? { try_files $uri /qa/index.php?qa-rewrite=$1&$query_string; } also the block if (!-e $request_filename) { rewrite ^(.+)$ /index.php?$1 last; } is better to be moved inside the / location and converted into try_files location / { index index.php index.html; try_files $uri /index.php?$request_uri } if you still are having trouble please tell me.

Categories : PHP

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

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

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

My nginx + fastcgi configuration downloads php files instead of executing them
Your php code is being displayed directly because it's not being sent to the php engine, that means the location block is being matched and the php file is being served, but the php file isn't being captured by the php block, so your problem is in the php block. In that block you have 2 fastcgi_pass, one with a port (9000) and the other to a unix socket, you can't have both together, but since you've tagged your question with fastcgi so I'll assume you are using fastcgi, try commenting this line #fastcgi_pass unix:/var/run/php5-fpm.sock;

Categories : Nginx

Varnish with Nginx for a Rails application (issue with Devise authentication)
You are preventing your backend to delete your session cookie, so you can't log out unless you explicitly delete your browsers' cookies. Looking at your fetch VCL (Comment inline): sub vcl_fetch { # This prevents server from deleting the cookie in the browser when loging out if(req.url ~ "logout" || req.url ~ "sign_out"){ unset beresp.http.Set-Cookie; } if (req.request == "GET") { unset beresp.http.Set-Cookie; set beresp.ttl = 360m; } if (req.url ~ "images/" || req.url ~ "javascripts" || req.url ~ "stylesheets" || req.url ~ "assets"){ set beresp.ttl = 360m; } } So your backend can't delete client's cookie unless as result of a POST request. IMHO you shouldn't mess with backend's Set-Cookie headers unless you know (and test well) posible side effects

Categories : Ruby On Rails



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