如何配置nginx代理传递

如何配置nginx代理传递,nginx,Nginx,我正在尝试启动我的nginx服务器,我得到了 nginx:[emerg]在/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; } ht

我正在尝试启动我的nginx服务器,我得到了

nginx:[emerg]在/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/;
    }
}
服务器{
听80;
服务器名称;
客户最大车身尺寸4M;
#将服务器错误页面重定向到静态页面/50x.html
#
错误\u第500页502 503 504/50x.html;
location=/50x.html{
root/usr/share/nginx/html;
}
#拒绝访问.htaccess文件,如果Apache的文档根
#同意nginx的观点
#
位置~/\.ht{
否认一切;
}
位置~/(媒体|静态| dl){
root/var/www/vhosts/tree/content/;
}
位置~^/([^/]+\.^/]+)${
root/var/www/vhosts/tree/content;
}
地点/{
uwsgi_通道unix:///tmp/spreeapp.sock;
包括uwsgi_参数;
uwsgi_param uwsgi_CHDIR/var/www/vhosts/tree;
uwsgi_参数uwsgi_文件调度.wsgi;
uwsgi_读取_超时300;
uwsgi_发送_超时120;
root/var/www/vhosts/tree;
}
位置=/favicon.ico{
返回204;
}
}
服务器{
听2080;
地点/媒体/{
root/var/www/vhosts/tree/content;
}
地点/{
访问\u log/var/log/nginx/remote.log main;
代理传递http://: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/;
    }
}
位置/{
分解器8.8.8.8;
访问\u log/var/log/nginx/remote.log main;
代理传递http://:80/app/remote/;
}
}

欢迎使用任何指针

以上配置的问题是无法连接到主机或url

试试这个

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

上述配置的问题是无法连接到主机或url

试试这个

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

您是否尝试过使用proxy_pass?刚刚尝试过,并在/etc/nginx/domains.d/spreeapp.conf:52 nginx:configuration file/etc/nginx/nginx.conf测试中获得了>nginx:[emerg]无效的URL前缀。在proxy_pass中不应签名。也许你是从某个教程中抄袭过来的。我很高兴它能起作用,让我来回答你的问题。你是否尝试过使用proxy_pass?刚刚尝试过并获得>nginx:[emerg]/etc/nginx/domains.d/spreeapp.conf:52 nginx:configuration file/etc/nginx/nginx.conf测试中的URL前缀无效代理\u pass中不应签名。也许你是从某个教程中抄袭过来的。我很高兴它奏效了,让我把它贴出来作为对你问题的回答