I have just brought a domain name (example.com) and have setup a URL frame redirection to my server's IP XXX.XXX.XXX.XXX, however I am getting a 403 forbidden error. I can access pages fine via the server IP. What I want is to copy the behavior of the server IP using my domain so I attempted to copy the virtual host for my IP but it doesnt work.
Here are my virtual host files:
server {
listen 80;
server_name example.com
;
access_log /var/log/nginx/website.access_log;
error_log /var/log/nginx/website.error_log;
root /var/www;
index index.html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/phpMyAdmin;
include fastcgi_params;
}
}
And my current one for accessing the server by the IP directly (works):
server {
listen 80;
server_name xxx.xxx.xxx.xxx
;
access_log /var/log/nginx/website.access_log;
error_log /var/log/nginx/website.error_log;
root /var/www;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/phpMyAdmin;
include fastcgi_params;
}
}
Here is my nginx.conf:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
autoindex off;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/default;
include /etc/nginx/sites-enabled/phpMyAdmin;
include /etc/nginx/sites-enabled/example.com;
}
I have also tried:
sudo chown -R www-data:www-data /var/www
sudo chmod -R 775 /var/www
Any advice would be greatly appreciated. Been on this one for a while now.
Thanks!
EDIT ------
The problem was with my domain registrar, I had my domain setup as "URL forwarding", when it should have been "A record". This fixed it for me. Good luck all!