nginx.conf ok - but want to redirect numeric IP to sitename

Almir Karic almir at kiberpipa.org
Wed Dec 10 16:52:39 MSK 2008


try searching the archives or checking the wiki :-)

what you want is "listen ... default;" in the server {}.

On Wed, Dec 10, 2008 at 06:12:07AM +0100, Stefan Scott wrote:
> Hi -
> 
> I installed nginx + PHP-FPM, and set up multiple Drupal sites using the
> "more secure" directory layout following the instructions from Justin
> Hileman:
> 
> http://justinhileman.info/blog/2007/06/a-more-secure-drupal-multisite-install
> 
> So far I've only configured site1.com to use Drupal, and site2.com and
> site3.com display "Welcome to Nginx" for now, which is fine, as I'll be
> configuring them to run Ruby on Rails sites.
> 
> To configure my nginx.conf file, I followed the instructions on these
> two sites:
> 
> http://www.codegobbler.com/drupal-nginx-fastcgi-setup-and-configuration
> http://drupal.org/node/110224
> 
> My current nginx.conf file is shown below.
> 
> Now as an additional test, I tried pointing my browser at my numeric IP
> address, eg:
> 
> http://208.77.188.166/     ## this is the official IP address of
> example.com
> 
> I hoped it would go by default to the first site in my nginx.conf file
> (site1.com) - but instead it goes to my Drupal installation page.
> 
> I don't want to expose this Drupal installation page to the public.
> 
> How do I change my ningx.conf file so that entering a numeric IP address
> in my browser will go to the first site in my nginx.conf file
> (site1.com)?
> 
> Here's my nginx.conf file:
> 
> user  www-data www-data;
> worker_processes  2;
> 
> error_log  logs/error.log;
> #error_log  logs/error.log  notice;
> #error_log  logs/error.log  info;
> 
> pid        logs/nginx.pid;
> 
> 
> events {
>     worker_connections  1024;
> }
> 
> 
> http {
>     include       mime.types;
>     default_type  application/octet-stream;
> 
>     #log_format  main  '$remote_addr - $remote_user [$time_local]
> $request '
>     #                  '"$status" $body_bytes_sent "$http_referer" '
>     #                  '"$http_user_agent" "$http_x_forwarded_for"';
> 
>     #access_log  logs/access.log  main;
> 
>     sendfile        on;
>     #tcp_nopush     on;
> 
>     keepalive_timeout  65;
> 
>     gzip on;
>     gzip_comp_level 1; gzip_proxied any;
>     gzip_types text/plain
>                text/html
>                text/css
>                application/x-javascript
>                text/xml
>                application/xml
>                application/xml+rss
>                text/javascript;
> 
>     server {
>         listen       80;
>         server_name  .site1.com;
> 
>         location / {
>             root   /usr/local/nginx/html/site1;
>             index  index.php;
>         }
> 
>         location / {
>             root   /usr/local/nginx/html/site1;
>             index  index.php index.html;
> 
>             if (!-e $request_filename) {
>                 rewrite  ^/(.*)$  /index.php?q=$1  last;
>                 break;
>             }
>         }
> 
>         # hide protected files
>         location ~*
> \.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$
> {
>             deny all;
>         }
> 
>         # hide backup_migrate files
>         location ~* ^/files/backup_migrate {
>             deny all;
>         }
> 
>         # serve static files directly
>         location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
>             root /usr/local/nginx/html/site1;
>             access_log        off;
>             expires           30d;
>             break;
>         }
> 
>         error_page  404              /index.php;
> 
>         error_page   500 502 503 504  /50x.html;
> 
>         location = /50x.html {
>             root   html;
>         }
> 
>         location ~ \.php$ {
>             root   html/site1;
>             fastcgi_pass 127.0.0.1:9000;
>             fastcgi_index index.php;
>             include /usr/local/nginx/conf/fastcgi_params;
>         }
>     }
> 
>     server {
>         listen       80;
>         server_name  .site2.com;
> 
>         location / {
>             root   html/site2;
>             index  index.html index.htm;
>         }
> 
>         error_page   500 502 503 504  /50x.html;
>         location = /50x.html {
>             root   html;
>         }
>     }
>     server {
>         listen       80;
>         server_name  .site3.com;
> 
>         location / {
>             root   html/site3.com;
>             index  index.html index.htm;
>         }
> 
>         error_page   500 502 503 504  /50x.html;
>         location = /50x.html {
>             root   html;
>         }
>     }
> }
> 
> Thanks!
> -- 
> Posted via http://www.ruby-forum.com/.
> 





More information about the nginx mailing list