我正在使用 Ubuntu 19.04,并且我将使用 Nginx(在 localhost:80)作为 Apache2(在 localhost:8080)和 Jenkins(在 localhost:8000)的代理(反向?)。
问题是:为什么全部图像没有加载?
我的配置是:
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/apache2
DirectoryIndex index.html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/apache2/sites-available/apache2.localhost.conf
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/apache2.localhost/www
DirectoryIndex index.html
ServerName apache2.localhost
ErrorLog /var/www/html/apache2.localhost/log/error.log
CustomLog /var/www/html/apache2.localhost/log/access.log combined
</VirtualHost>
/etc/nginx/站点可用/默认
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/nginx;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location /apache2/ {
proxy_buffering off;
proxy_pass http://apache2.localhost:8080/;
}
location /jenkins/ {
proxy_buffering off;
proxy_pass http://localhost:8000/;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
答案1
我已经根据有关詹金斯的指南部分解决了该问题:
https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy
这是我的配置文件(/etc/nginx/sites-available/default):
server {
listen 80 default_server;
listen [::]:80 default_server;
location /jenkins/ {
proxy_pass http://127.0.0.1:8000/jenkins/;
sendfile off;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
# This is the maximum upload size
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_temp_file_write_size 64k;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off; # Required for HTTP-based CLI to work over SSL
}
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
}
我会尽快发布完整的解决方案