2014-11-02 29 views
1

到proxy_pass mailcather我有以下的nginx的conf無法使用nginx的

upstream domain1 { 
    server 127.0.0.1:3000; 
    server 127.0.0.1:3001; 
} 




server { 
    listen 80; 
    server_name demo.domain.com; 

    root /var/apps/myapp/public; 

    location/{ 
       proxy_set_header X-Real-IP $remote_addr; 
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
       proxy_set_header Host $http_host; 
       proxy_redirect off; 

       if (-f $request_filename/index.html) { 
           rewrite (.*) $1/index.html break; 
       } 

       if (-f $request_filename.html) { 
           rewrite (.*) $1.html break; 
       } 

       if (!-f $request_filename) { 
           proxy_pass http://domain1; 
           break; 
       } 
    } 

location /mail_us1 { 
       proxy_pass  http://127.0.0.1:1080; 
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
       proxy_set_header Host $http_host; 
} 


} 

我想設置我的服務器上mailcatcher

與我的nginx的經驗有限(mailcatcher在1080端口上運行)我假設以下指令將工作良好

location /mail_us1 { 
        proxy_pass  http://127.0.0.1:1080; 
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
        proxy_set_header Host $http_host; 
    } 

但不幸的是,我無法獲得所需的輸出,我keepi NG獲取有關nginx的網頁登陸,指出

No Dice 

The message you were looking for does not exist, or doesn't have content of this type. 

任何一個可以告訴我,我做錯了什麼

注:

- curl http://localhost:1080 (work) 

- iptables -L (is empty) 

回答

2

這個工作對我來說:

location /mailcatcher { 
    rewrite /mailcatcher/(.*) /$1 break; 
    proxy_pass http://mailcatcher/; 
} 

location ~ ^/assets { 
    proxy_pass http://mailcatcher; 
} 

location ~ ^/messages { 
    proxy_pass http://mailcatcher; 
    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
} 
+0

你正在做什麼與主機文件?你怎麼設置'http:// mailcatcher'是什麼? – 2016-02-08 22:22:45