the nginx configuration file under your server ubuntu,
modify its configuration in etc/nginx/sites-ava/default.
If you want to prohibit IP access, you only need to add your server name.
The following code removes the comment # part
server { listen 80; [b]server_name www.test.com www.test2.com; [/b] listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html/3dvr; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
如果需要绑定更多域名,可以添加域名列表,放在配置文件夹下,但是文件要以.conf后缀名。即上层目录的nginx.conf下,然后在default文件中include进来就可以了
像这样
include /etc/nginx/conf.d/*.conf;
================================================================
三、不带www的域名加301跳转
若不带 www 的域名需加 301 跳转,则先绑定不带 www 的域名,且无需写网站目录,直接进行 301 跳转,如:
server { listen 80; server_name server110.com; rewrite ^/(.*) http://www.server110.com/$1 permanent; }
四、添加404网页
添加 404 网页,可以直接在配置中添加,如:
server { listen 80; server_name www.server110.com; #绑定域名 index index.htm index.html index.php; #默认文件 root /home/www/server110.com; #网站根目录 include location.conf; #调用其他规则,也可去除 error_page 404 /404.html; }
Source below
https://help.aliyun.com/knowledge_detail/41467.html