導航:首頁 > IDC知識 > nginx配置泛二級域名

nginx配置泛二級域名

發布時間:2020-10-18 11:01:05

1、nginx https怎麼配置二級域名問題

Nginx安裝SSL證書:網頁鏈接

Nginx 自動跳轉到HTTPS:網頁鏈接

SSL證書技術支持:網頁鏈接

2、Nginx怎麼綁定二級域名 綁了沒法PHP

方案1.
Ftp根目錄建立一個新的目錄test(第二個站)
將xx.xx.com綁定至主站
寫一個腳本,
規則回: 一旦訪問xx.xx.com 自動跳轉答 訪問根目錄下的test目錄。

方案2.
同樣創建test文件夾
以xx.com/test的方式訪問

3、Nginx如何配置二級域名

和頂級域名一樣的設置。只是把servername 改成你的二級域名就可以了

4、nginx如何設置,使www二級域名綁定根目錄,其他二級域名綁定子目錄

這個應該是要從程序上設置

5、nginx配置二級域名後,系統所有url都需要加上相應的二級域名前綴嗎

如果你原來系統使用的都是絕對路徑,那麼很遺憾,所有的URL必須都改變
如果原來的系統使用的都是相對路徑,那麼恭喜你,不需要修改任何URL

6、nginx如何綁定二級域名

nginx綁定二級域名是通過編輯配置文件中的server 的server_name來處理的。

如:

 server {
        listen       8001;
        server_name  domain_name;

        #charset koi8-r;

        #access_log  logs/access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
    }

7、nginx https怎麼配置二級域名問題

請參考代碼,https如果監聽的是443埠,則網址後面不需要加埠;如果監聽的不是443埠則需要加埠。如下圖的 https://*.9yyule.com:8888

#user  nobody;
worker_processes  4;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;

pid        logs/nginx.pid;


events {
    worker_connections  65535;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

   log_format  main  '$remote_addr - $remote_user [$time_local] "$request"'
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;
    # server_names_hash_bucket_size 128K;

      client_header_buffer_size 32k;

      large_client_header_buffers 4 32k;
       client_body_buffer_size    8m;
        server_tokens off;
    ignore_invalid_headers   on;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  65;
proxy_temp_path   /usr/local/nginx-1.8/proxy_temp;
proxy_cache_path /usr/local/nginx-1.8/proxy_cache levels=1:2 keys_zone=cache_one:100m inactive=2d max_size=10g;
    gzip  on;
    gzip_disable "MSIE [1-6].(?!.*SV1)";
    gzip_min_length  1k;         
    gzip_buffers     4 16k;       
    gzip_http_version 1.0;       
    gzip_comp_level 2;           
    gzip_types   text/plain application/x-javascript text/css application/xml;          

server {
                listen       80 default;
                return 500;
                server_tokens off;
                root html;      }
#server {
              # listen  443  default;
             #  return 500;
            #   server_tokens off;
           #   root html;      }

    
 upstream name {
          # server 116.31.118.114:8098  weight=2 fail_timeout=3s  backup; 
           server 114.55.32.244:888  weight=1 max_fails=3 fail_timeout=300;
          server 114.55.85.154:8080  weight=1 max_fails=3 fail_timeout=300;    
           ip_hash;             
    }
 

       server {
       listen 8888  default ;
        server_name  *.9yyule.com *.jiuyiyule.com *.yinqicai.com;
      server_tokens off;
        ssl on; 
       ssl_certificate /usr/local/nginx/conf/web.crt;
       ssl_certificate_key /usr/local/nginx/conf/web.key;
      error_page 497  https://$host:$server_port$request_uri;  
        location ~*/{ 
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://name;
        proxy_http_version 1.1;
        proxy_set_header  Accept-Encoding  "";          
            
    location ~ .*.(gif|jpg|png|html|css|js|ico|swf|pdf)(.*) {
            proxy_pass http://name;
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header   X-Real-IP   $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_cache cache_one;
            add_header Nginx-Cache $upstream_cache_status;
            proxy_cache_valid  200 304 301 302 24h;
            proxy_cache_valid 404 1m;
            proxy_cache_valid  any 2d;
            proxy_cache_key $host$uri$is_args$args;
            expires 7d;
        }       



      location ~ /purge(/.*)

      {

          auth_basic "TDT  Center  CACHE  Center";

          auth_basic_user_file /tmp/htpasswd;

          allow 127.0.0.1;


          deny all;

          proxy_cache_purge cache_one $host$1$is_args$args;

      }

 

       # error_page  404              /404.html;
       #  error_page   400 501 502 503 504  https://$host:$server_port$request_uri;
       # location = /50x.html {
       #     root   html;
      #  }


        # redirect server error pages to the static page /50x.html
        #
     #   error_page   500 502 503 504  /50x.html;
       
}
}

8、nginx中怎麼配置泛域名指向呢?

這個簡單。在nginx中,server域中的server_name指令可以採用完整的精確匹配、正則表達式匹配、通配符匹配的形式。

一般而言,匹配的過程為:

1. 精確匹配,比如www.xxx.com;
2. 以*通配符開始的最長的通配符匹配,比如*.xxx.com;
3. 以*通配符結束的最長的通配符匹配,比如www.xxx.*;
4. 第一次匹配成功的正則表達式;比如~^ xxx


因此此處有兩種配置方式,一種是使用通配符,另一種是採用正則表達式:

法一:

server{
#...
server_name *.xxx.com;
#...
}


法二:

server {
#...
server_name ~^ xxx;
#...
}

9、amh怎麼nginx配置二級域名

一、新建rewrite規則,復制下面的規則然後另存為wp2.conf

location /wordpress/ {

if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}

if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}

if (!-f $request_filename){
rewrite (.*) /wordpress/index.php;
}
}

二、注意上面的wordpress目錄,假設你的二級目錄或為blog則將上面兩處修改為blog

三、將創建的wp2.conf存放至伺服器/usr/local/nginx/conf/rewrite目錄中

三、打開/usr/local/nginx/conf/vhost目錄,找到網站的配置文件,比如小z博客的是xiaoz.me.conf在server{}引入新增的wp2.conf文件include rewrite/wp2.conf;保存並覆蓋,如果怕改錯,建議先備份。

四、最後重啟nginx伺服器,amh nginx restart

10、求助高手,Nginx配置二級域名跳轉 地址欄不變咋處理?

做域名鏡像的rewrite即可
rewrite ^/(.*)$ http://二級域名/$1 last;

與nginx配置泛二級域名相關的知識