Nginx進(jìn)行域名重寫和泛域名解析配置的方法
本文介紹了Nginx進(jìn)行域名重寫和泛域名解析配置的方法,分享給大家,具體如下:
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } 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; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; #設(shè)置允許發(fā)布內(nèi)容為8M client_max_body_size 20M; client_body_buffer_size 512k; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-With; add_header Access-Control-Allow-Methods GET,POST,OPTIONS; server { listen 80; server_name www.xxx.com; location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name www.aaa.com; location / { proxy_pass http://127.0.0.1:9989; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } #泛域名解析 server { listen 80; server_name *.web.yuyuyun.cn; location / { # 泛域名開始配置 if ( $host ~* (.*)\.(.*)\.(.*)\.(.*) ) { set $domain $1; #獲取當(dāng)前的 域名前綴 } proxy_pass http://127.0.0.1:1119/$domain/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
把ImageMagic庫(kù)編譯進(jìn)nginx服務(wù)器的一些必要配置
這篇文章主要介紹了把ImageMagic庫(kù)編譯進(jìn)nginx服務(wù)器的一些必要配置,本文給出了操作步驟和配置參數(shù)示例,需要的朋友可以參考下2015-06-06Nginx+FastDFS搭建圖片服務(wù)器的方法實(shí)現(xiàn)
這篇文章主要介紹了Nginx+FastDFS搭建圖片服務(wù)器的方法實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03nginx強(qiáng)制使用https訪問的方法(http跳轉(zhuǎn)到https)
這篇文章主要介紹了nginx強(qiáng)制使用https訪問的方法(http跳轉(zhuǎn)到https),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-01-01安裝配置php-fpm來搭建Nginx+PHP的生產(chǎn)環(huán)境
這篇文章主要介紹了安裝配置php-fpm來搭建Nginx+PHP的生產(chǎn)環(huán)境的方法,php-fpm的作用是將FastCGI進(jìn)程管理整合進(jìn)PHP包,需要的朋友可以參考下2016-01-01Nginx?map?實(shí)現(xiàn)時(shí)間格式轉(zhuǎn)換的方法
最近我們需要把?Nginx?的日志接入到自研的日志采集平臺(tái)上,但是這個(gè)平臺(tái)只支持?JSON?格式,所以需要把?Nginx?日志格式改成?JSON?格式,這篇文章主要介紹了Nginx?map?實(shí)現(xiàn)時(shí)間格式轉(zhuǎn)換,需要的朋友可以參考下2023-09-09nginx正向代理http和https的實(shí)現(xiàn)步驟
本文主要介紹了nginx正向代理http和https的實(shí)現(xiàn)步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07