configurationNGINX以正确地将URL转发到Graphite docker映像

我有一个通过NGINX和UWSGI在Debian上运行的Web应用程序。 我们已经开始使用在Docker容器中运行的Graphite和statsd来收集应用程序的统计信息(来自https://github.com/hopsoft/docker-graphite-statsd )。 docker集装箱有自己的NGINX服务石墨。 目前我们正在运行docker容器转发端口8081到80,并能够通过http:// example.com:8081访问Graphite。

我正在尝试通过现有的NGINX服务器为Graphite路由networkingstream量,以便我们能够在访问时使用我们build立的身份validation方法。

我希望能够通过example.com/graphite/访问Graphite,并在该目录下引用所有关联的内容。

目前example.com/graphite/转发到http:// example.com:8091/graphite/。 我想要的URL不会改变。 从那里,Graphite加载,但所有的页面元素从8091 /加载,例如http:// example.com:8091/content/js/ext/resources/images/default/sizer/s-handle.gif,而我希望通过http:// example.com/graphite/content/js/ext/resources/images/default/sizer/s-handle.gif来引用它。

当我去domain.com/graphite/admin/时,我收到我们的Web应用程序的404页面。 pipe理页面的html已经成功加载,但是我收到了https:// example.com/browser/header/和https:// example.com/composer/?404。

这里是我当前nginx.conf的相关部分:

# HTTPS server server { listen 443; listen 8000; server_name $hostname; ssl on; etag on; # used in tests ssl_verify_client optional; ssl_verify_depth 2; location /graphite { rewrite ^/graphite(/.*)$ $1 break; proxy_pass http://localhost:8091; proxy_set_header HOST $host; proxy_redirect http://127.0.0.1:8091/graphite/ http://$host/graphite/; } location /graphite/admin { rewrite ^/graphite(/.*)$ $1 break; proxy_pass http://localhost:8091; proxy_set_header HOST $host; proxy_redirect http://127.0.0.1:8091/graphite/ http://$host/graphite/; } location / { uwsgi_pass unix:///tmp/web2py.socket; include uwsgi_params; uwsgi_param SSL_CLIENT_ID $ssl_client_s_dn; uwsgi_param REMOTE_USER $ssl_client_s_dn; uwsgi_param UWSGI_SCHEME $scheme; #Values to relay from nginx to uwsgi uwsgi_param SSL_CLIENT_CERT $ssl_client_cert; uwsgi_param SSL_CLIENT_RAW_CERT $ssl_client_raw_cert; uwsgi_param SSL_CLIENT_VERIFY $ssl_client_verify; uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; } } upstream django { # server unix:///path/to/your/mysite/mysite.sock; # for a file socket server 127.0.0.1:8081; # for a web port socket (we'll use this first) } # graphite server { listen 8091; server_name $hostname; # substitute your machine's IP address or FQDN charset utf-8; ssl off; # max upload size client_max_body_size 75M; # adjust to taste location /graphite/ { proxy_pass http://127.0.0.1:8081/; proxy_redirect http://127.0.0.1:8081/graphite/ http://$host/graphite/; proxy_set_header HOST $host; proxy_set_header SCRIPT_NAME /graphite; } location / { proxy_pass http://127.0.0.1:8091/graphite/; } } 

以下是Docker镜像中的/etc/nginx/sites-enabled/graphite-statsd.conf:

 server { listen 80; root /opt/graphite/webapp/content; index index.html; location /media { # django admin static files alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/media/; } location /admin/auth/admin { alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin; } location /admin/auth/user/admin { alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin; } location / { # checks for static file, if not found proxy to app try_files \$uri @app; } location @app { include fastcgi_params; fastcgi_split_path_info ^()(.*)$; fastcgi_pass 127.0.0.1:8080; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type'; add_header 'Access-Control-Allow-Credentials' 'true'; } } 

我对configurationNGINX相当陌生,以前从未使用django,所以我确信我的configuration有几个问题。 任何帮助非常感谢! 道歉的url中的空格。