【发布时间】:2016-11-21 20:49:08
【问题描述】:
以前,我使用 Apache 代理托管了我的 NodeJS 应用程序,并在虚拟主机中进行了以下配置。
<VirtualHost *:80>
ServerName api.mydomain.com
ProxyPreserveHost On
ProxyPass / http://localhost:8090/
ProxyPassReverse / http://localhost:8090/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
现在由于 GitLab 的依赖,我已经搬到 NGINX。
现在是/etc/nginx/sites-available/api.mydomain.com下的虚拟主机
server {
listen 80;
server_name api.mydomain.com;
location / {
proxy_pass http://localhost:8090;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
但域加载主要主机内容,而不是 nodejs 应用程序。
nginx版本nginx/1.10.1,ubuntu版本16.04
以下是我为 gitlab 拥有的唯一另一个虚拟主机,
upstream gitlab-workhorse {
server unix:/var/opt/gitlab/gitlab-workhorse/socket;
}
## Normal HTTP host
server {
## Either remove "default_server" from the listen line below,
## or delete the /etc/nginx/sites-enabled/default file. This will cause gitlab
## to be served if you visit any address that your server responds to, eg.
## the ip address of the server (http://x.x.x.x/)n 0.0.0.0:80 default_server;
listen 0.0.0.0:80 default_server;
listen [::]:80 default_server;
server_name gitlab.mydomain.com
server_tokens off; ## Don't show the nginx version number, a security best practice
root /opt/gitlab/embedded/service/gitlab-rails/public;
## See app/controllers/application_controller.rb for headers set
## Individual nginx logs for this GitLab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;
location / {
client_max_body_size 0;
gzip off;
## https://github.com/gitlabhq/gitlabhq/issues/694
## Some requests take more than 30 seconds.
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://gitlab-workhorse;
}
}
【问题讨论】:
-
目前,通过同时运行 nginx 和 apache 作为代理解决了这个问题。但仍在寻找问题。
标签: node.js apache ubuntu nginx gitlab