0
我已經設置了我的nginx配置,我在同一端口上運行兩個網站。我的問題是我不想指定端口號,只要我打開我的網站。我正在運行我的網站上端口81.我的問題是,如果我有這兩個網站abc.com:81和xyz.com:81。我需要包括端口號,同時打開它們,我不想要這樣任何人都可以告訴我可能的解決方案..配置nginx爲不同的端口
這裏是我的nginx的配置
user abc;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
passenger_root /usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.30;
passenger_ruby /usr/local/rvm/gems/ruby-2.2.3/wrappers/ruby;
passenger_max_pool_size 50;
passenger_min_instances 5;
passenger_max_instances_per_app 0;
passenger_pool_idle_time 0;
passenger_max_preloader_idle_time 0;
passenger_app_env staging;
passenger_friendly_error_pages on;
server {
listen 81 default_server;
passenger_enabled on;
server_name abc.com;
root /var/www/project/current/public;
location/{
}
error_page 404 /404.html;
location = /40x.html {
root /var/www/project/current/public;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/project/current/public;
}
}
server {
listen 81 ;
passenger_enabled on;
root /var/www/new_project/current/public;
server_name xyz.com;
if (-f $document_root/system/maintenance.html)
{
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
error_page 500 502 503 504 /500.html;
location = /500.html
{
root /var/www/new_project/current/public;
}
error_page 404 /404.html;
location = /404.html
{
root /var/www/new_project/current/public;
}
}
}
我想概念上你所做的是爲每個服務器配置一個「位置」,都在端口80「listen」塊內。即'/ server_a'和'/ server_b'。然後你會讓這些位置塊調用'proxy_pass'到你的其他端口。 –