如何配置nginx代理传递

时间:2016-04-02 21:33:46

标签: nginx

我正在尝试启动我的nginx服务器而我正在

  

nginx:[emerg]主机在上游找不到“< 192.168.0.1>”在/etc/nginx/domains.d/spreeapp.conf:52

我的nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
worker_connections  1024;
}


http {
include       /etc/nginx/mime.types;
default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

keepalive_timeout  65;

#gzip  on;

include /etc/nginx/domains.d/*.conf;
}

spreeapp.conf

server {
listen       80;
server_name  _;
client_max_body_size 4M;

# 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;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
    deny  all;
}

location ~ /(media|static|dl) {
    root   /var/www/vhosts/tree/content/;
}

location ~ ^/([^/]+\.[^/]+)$ {
    root   /var/www/vhosts/tree/content;
}

location / {
    uwsgi_pass   unix:///tmp/spreeapp.sock;
    include        uwsgi_params;
    uwsgi_param UWSGI_CHDIR /var/www/vhosts/tree;
    uwsgi_param UWSGI_FILE dispatch.wsgi;
    uwsgi_read_timeout 300;
    uwsgi_send_timeout 120;
    root   /var/www/vhosts/tree;
}

location = /favicon.ico {
    return 204;
    }
}

server {
listen       2080;

location  /media/ {
    root   /var/www/vhosts/tree/content;
}

location / {
    access_log  /var/log/nginx/remote.log  main;
    proxy_pass http://<192.168.43.1>:80/app/remote/;
    }
}

我尝试将解析器放在下面没有运气

location / {
    resolver 8.8.8.8;
    access_log  /var/log/nginx/remote.log  main;
    proxy_pass http://<192.168.0.1>:80/app/remote/;
    }
}

欢迎任何指示

1 个答案:

答案 0 :(得分:0)

上述配置的问题在于它无法连接到主机或网址。

试试这个

location / {
    access_log  /var/log/nginx/remote.log  main;
    proxy_pass http://192.168.43.1:80/app/remote/;
    }