Answer the question
In order to leave comments, you need to log in
How to handle non-existent domains in nginx?
Good day to all!
I spent a long time digging with the transfer of my Joomla from Apache to the nginx PHP-FPM server, in the end I did everything I wanted, but there was such a problem: The
site began to open by IP, googled and found this code
server {
listen 80;
server_name xx.xxx.xxx.xx;
rewrite ^/(.*)$ http://site.ru/$1 permanent;
}
user www-data;
worker_processes 8;
pid /run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
include /etc/nginx/vhosts/*/*;
server {
server_name localhost;
disable_symlinks if_not_owner;
listen xx.xxx.xxx.xx:80 default;
include /etc/nginx/vhosts-includes/*.conf;
location @fallback {
error_log /dev/null crit;
proxy_pass http://127.0.0.1:8080;
proxy_redirect http://127.0.0.1:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
access_log off ;
}
}
}
server {
charset off;
disable_symlinks if_not_owner from=$root_path;
index index.html index.php;
root $root_path;
set $root_path /var/www/webkilla/data/www/site.ru;
access_log /var/www/httpd-logs/site.ru.access.log ;
error_log /var/www/httpd-logs/site.ru.error.log notice;
listen xx.xxx.xxx.xx:80 default;
server_name site.ru www.site.ru;
include /etc/nginx/vhosts-includes/*.conf;
location /administrator/ {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location / {
expires 1d;
# Enable joomla SEF URL's inside Nginx
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
fastcgi_pass unix:/var/www/php-fpm/webkilla.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
ssi on;
}
Answer the question
In order to leave comments, you need to log in
Create a new virtual host (server section) and write to it
And also read how nginx handles requests .
Please note that there can be only one virtual host with the default_server directive.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question