Nginx進行域名重寫和泛域名解析配置的方法
更新時間:2019年08月26日 10:23:49 作者:妖月風
這篇文章主要介紹了Nginx進行域名重寫和泛域名解析配置的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
本文介紹了Nginx進行域名重寫和泛域名解析配置的方法,分享給大家,具體如下:
#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; #獲取當前的 域名前綴
}
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;
}
}
}
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
把ImageMagic庫編譯進nginx服務(wù)器的一些必要配置
這篇文章主要介紹了把ImageMagic庫編譯進nginx服務(wù)器的一些必要配置,本文給出了操作步驟和配置參數(shù)示例,需要的朋友可以參考下2015-06-06
Nginx+FastDFS搭建圖片服務(wù)器的方法實現(xiàn)
這篇文章主要介紹了Nginx+FastDFS搭建圖片服務(wù)器的方法實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-03-03
nginx強制使用https訪問的方法(http跳轉(zhuǎn)到https)
這篇文章主要介紹了nginx強制使用https訪問的方法(http跳轉(zhuǎn)到https),具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-01-01
安裝配置php-fpm來搭建Nginx+PHP的生產(chǎn)環(huán)境
這篇文章主要介紹了安裝配置php-fpm來搭建Nginx+PHP的生產(chǎn)環(huán)境的方法,php-fpm的作用是將FastCGI進程管理整合進PHP包,需要的朋友可以參考下2016-01-01
Nginx?map?實現(xiàn)時間格式轉(zhuǎn)換的方法
最近我們需要把?Nginx?的日志接入到自研的日志采集平臺上,但是這個平臺只支持?JSON?格式,所以需要把?Nginx?日志格式改成?JSON?格式,這篇文章主要介紹了Nginx?map?實現(xiàn)時間格式轉(zhuǎn)換,需要的朋友可以參考下2023-09-09
nginx正向代理http和https的實現(xiàn)步驟
本文主要介紹了nginx正向代理http和https的實現(xiàn)步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-07-07

