以前,我使用Apache代理托管了我的NodeJS应用程序,并在虚拟主机中进行了以下配置。在nginx中创建虚拟主机以托管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>
现在我已经搬到NGINX
因为GitLab依赖。
现在虚拟主机/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作为代理运行来解决问题。但仍然在寻找这个问题。 – devo