How can I access my Nginx website via its IP address?
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
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;
fastcgiintercepterrors on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_pass php;
fastcgi_index index.php;
fastcgiparam SCRIPTFILENAME /srv/www/sitename.com/public_html
}
location = /favicon.ico {
lognotfound off;
access_log off;
}
location = /robots.txt {
allow all;
lognotfound off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
lognotfound off;
}
}
Any help is appreciated! Thanks.
2 Replies
Good luck!
-Chris
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;
...
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;
...