Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Dec 09, 2013 8:16 pm 
Offline
Newbie

Joined: Fri Oct 11, 2013 1:55 pm
Posts: 4
I have several websites on my linode LEMP stack (using nginx instead of apache). Each site lives in a separate folder /srv/www/sitename.com, where sitename is the name of the respective site.

I'm trying to migrate one site from it's previous host but I dont want to change the DNS records until the site is setup. However, I can't figure out how to access the site without it's domain name. I've tried IP-address/sitename.com but that just redirects me to my default_server.

Each domain has a configuration file in /etc/nginx/sites-available that looks something like this (below). What should I add to the configuration so that I can access the site with the ip address instead the sitename?:

server {
listen 80;
server_name www.sitename.com sitename.com;
access_log /srv/www/sitename.com/logs/access.log;
error_log /srv/www/sitename.com/logs/error.log;
root /srv/www/sitename.com/public_html;
index index.php;

rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/sitename.com/public_html
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}

Any help is appreciated! Thanks.


Top
   
PostPosted: Mon Dec 09, 2013 8:20 pm 
Offline
Linode Staff
User avatar

Joined: Tue Apr 15, 2003 6:24 pm
Posts: 3090
Website: http://www.linode.com/
Location: Galloway, NJ
Edit your LOCAL computer's /etc/hosts file and add an entry for the IP and domain name you're trying to test. Your LOCAL computer uses this file FIRST when trying to resolve hostnames. This allows you to redirect your LOCAL computer to a different IP for a given hostname, without mucking with global DNS or server side changes.

Good luck!
-Chris


Top
   
PostPosted: Tue Dec 10, 2013 2:44 pm 
Offline
Senior Member

Joined: Thu Jun 13, 2013 7:32 am
Posts: 79
I have /etc/nginx/sites-available/default pointing to srv/www/default/public_html, it loads a plain html file when the IP is placed in browser. To test a new site before DNS, I change root to "root /srv/www/sitename.com/public_html;" to point the IP to the site I just migrated. When all is tested, I put default back and place /etc/nginx/sites-available/sitename.com so it's ready to go.

Code:
server {
listen 80;
server_name 123.45.67 my.fqdn.com;
access_log /srv/www/default/logs/access.log;
error_log /srv/www/default/logs/error.log;
root /srv/www/default/public_html;
...

Code:
server {
listen 80;
server_name 123.45.67 my.fqdn.com;
access_log /srv/www/default/logs/access.log;
error_log /srv/www/default/logs/error.log;
root /srv/www/sitename.com/public_html;
...


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group