You are not logged in.

#1 2015-02-26 12:13:12

xanb
Member
Registered: 2012-07-24
Posts: 420

[solved] nginx serving trac as proxy: "Environment not found"?

Hi,

I get "Environment not found" in my browser when I try to access to trac with my browser.

I have tracd server running:

# tracd -d -p 8080 --auth *,/etc/trac/passwordstrac.txt,openbouche login /srv/http/tasks/openbouche

and I can access it directly.

But when I acces via nginx, I get "Environment not found". This is my nginx.conf:

[root@mercuri xan]# cat /etc/nginx/nginx.conf 

#user html;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout  65;

    # Compression
    gzip            on;
    gzip_min_length 1000;
    gzip_types      text/plain application/xml;

    # Main server configuration
    server {
        listen       80;
        server_name  localhost;

        charset utf-8;

        location / {
	    auth_basic	"closed site";
	    auth_basic_user_file conf/accesspwd.txt;
            root   /usr/share/nginx/html;
            index  index.html index.htm index.php;
        }

        # runs php-fpm for php files
        location ~ ^/sqladmin.+.php$ {
                 root /usr/share/nginx/html/;
                 try_files      $uri =404;
                 fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
                 fastcgi_index  index.php;
                 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                 fastcgi_intercept_errors on;
                 include	fastcgi_params;
                 include        fastcgi.conf;
        }

	# runs trac via FastCGI
	location ~ /tasks/ {
        	proxy_pass http://127.0.0.1:8080;
		#proxy_redirect on;
		proxy_set_header Host $host;
		proxy_http_version 1.1;
		proxy_set_header   X-Real-IP        $remote_addr;
	}

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

    }


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
[root@mercuri xan]# 

The access.log gives me 404 error:

83.42.123.179 - xan [26/Feb/2015:13:09:18 +0100] "GET /tasks/ HTTP/1.1" 404 21 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"

What is that? I can't find anything in Google.

Any hint?

Thanks,

Last edited by xanb (2015-02-27 12:16:51)


Owning one OpenRC (artoo way) and other three systemd machines

Offline

#2 2015-02-27 12:16:35

xanb
Member
Registered: 2012-07-24
Posts: 420

Re: [solved] nginx serving trac as proxy: "Environment not found"?

Solved:

nginx behaves correctly but it's missconfigured. With

        # runs trac
        location /tasks/ {
                proxy_pass http://127.0.0.1:8080/;
                proxy_http_version 1.1;
        }

The slash at the end of proxy_pass is crucial. If you don't pass it, then, nginx redirects yourfrontend/tasks/ to 127.0.0.1:8080/tasks/ (see the previous link)


Owning one OpenRC (artoo way) and other three systemd machines

Offline

#3 2015-02-27 14:07:45

xanb
Member
Registered: 2012-07-24
Posts: 420

Re: [solved] nginx serving trac as proxy: "Environment not found"?

Another alternative is:

        # runs trac
        location ~ ^/openbouche {
                proxy_pass http://127.0.0.1:8080;
                proxy_redirect default;
                #proxy_set_header Host $host;
                #proxy_http_version 1.1;
                #proxy_set_header X-Forwarded-Host $host;
                #proxy_set_header X-Forwarded-Server $host;
                #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header   X-Real-IP        $remote_addr;
        }

I don't know how to map /tasks to 127.0.0.1:8080/openbouche....


Owning one OpenRC (artoo way) and other three systemd machines

Offline

Board footer

Powered by FluxBB