public
Created

nginx config domain

  • Download Gist
lecai360_com.conf
1 2 3 4 5 6 7 8 9 10 11 12 13
# lecai360.com ,www.lecai360.com 分别独立访问
 
server{
 
listen 80;
 
server_name lecai360.com www.lecai360.com;
 
root /web/projects/lecai/current/public;
 
passenger_enabled on;
 
}
proxy_pass.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
# http://ronbin.com/311.htm?replytocom=245
# nginx反向代理后端的 wordpress(apache+php),wp地址是 http://wxianfeng.com:8080
# 前端地址 http://www.vic360.com
 
# nginx配置
upstream vic360_com {
server 127.0.0.1:8080;
}
 
server {
listen 80;
server_name www.vic360.com;
 
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
if (!-f $request_filename){
proxy_pass http://vic360_com;
break;
}
}
 
}
 
# apache 配置
>vi /etc/httpd/conf/httpd.conf
Listen 8080
 
NameVirtualHost *:8080
 
<VirtualHost *:8080>
ServerName www.vic360.com
DocumentRoot /usr/local/system/www/vic360
<Directory />
Options FollowSymLinks
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
ssl.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
# 配置 https://wxianfeng.com
# 注意编译nginx时加上 --with-http_ssl_module , 如果当初忘记, 可重新编译
 
upstream wxianfeng_com {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
 
server {
listen 80;
server_name www.wxianfeng.com;
rewrite ^/(.*) http://wxianfeng.com/$1 permanent;
}
 
server {
listen 80;
server_name wxianfeng.com;
 
access_log /usr/local/system/nginx/logs/access.log;
error_log /usr/local/system/nginx/logs/error.log;
 
root /usr/local/system/www/wxianfeng_com/current/public/;
index index.html;
 
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
 
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
 
if (!-f $request_filename) {
proxy_pass http://wxianfeng_com;
break;
}
}
 
}
 
 
upstream ssl {
server 127.0.0.1:80;
}
 
server {
server_name wxianfeng.com;
listen 443;
ssl on;
ssl_certificate /usr/local/system/nginx/conf/server.crt;
ssl_certificate_key /usr/local/system/nginx/conf/server.key;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host wxianfeng.com;
proxy_redirect off;
 
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
 
if (!-f $request_filename) {
proxy_pass http://ssl;
break;
}
}
 
}
store_lecai360_com.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
# store.lecai360.com 反向代理访问
 
upstream store_lecai360_com {
server 192.168.66.10:80;
}
 
 
server {
listen 80;
server_name store.lecai360.com;
 
access_log /usr/local/nginx/logs/access.log;
error_log /usr/local/nginx/logs/error.log;
 
 
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host store.lecai360.com;
proxy_redirect off;
 
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
 
if (!-f $request_filename) {
proxy_pass http://store_lecai360_com;
break;
}
}
 
}
wxianfeng_com.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
# www.wxianfeng.com rewrite to wxianfeng.com
 
upstream wxianfeng_com {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
 
server {
listen 80;
server_name www.wxianfeng.com;
rewrite ^/(.*) http://wxianfeng.com/$1 permanent;
}
 
server {
listen 80;
server_name wxianfeng.com;
 
access_log /usr/local/system/nginx/logs/access.log;
error_log /usr/local/system/nginx/logs/error.log;
 
root /usr/local/system/www/wxianfeng_com/current/public/;
index index.html;
 
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
 
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
 
if (!-f $request_filename) {
proxy_pass http://wxianfeng_com;
break;
}
}
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.