我已成功配置nginx。與默認網站它工作正常。 現在我有2個網站,一個在/ home/bugz和另一個/ home/git/github/public。只有一個IP 10.10.10.10(我沒有DNS設置,因此不能使用域名) 我想有網站在位置服務nginx一個ipaddress但從子文件夾服務的2個站點
http://10.10.10.10/bugz and http://10.10.10.10/github respectively
下面
是兩個配置文件
server {
listen *:80;
server_name 10.10.10.10;
server_tokens off;
root /home/bugz;
# individual nginx logs for this gitlab vhost
access_log /var/log/nginx/bugzilla_access.log;
error_log /var/log/nginx/bugzilla_error.log;
location /bugz {
index index.html index.htm index.pl;
}
location ~ \.pl|cgi$ {
try_files $uri =404;
gzip off;
fastcgi_pass 127.0.0.1:8999;
fastcgi_index index.pl;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
和
upstream gitlab {
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}
server {
# listen *:80 default_server; # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
listen *:80; # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
server_name 10.10.10.10; # e.g., server_name source.example.com;
server_tokens off; # don't show the version number, a security best practice
root /home/git/gitlab/public;
# individual nginx logs for this gitlab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;
location /{
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}
# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://gitlab;
}
}
我該如何做到這一點?
只配置1個網站,你在你的config目錄使用'網站,available'? – ProfessionalAmateur
是我的配置文件中使用的站點可用 – sparkbird