[英]NGINX proxy_pass http://localhost:9999/ Not Found
I run my webapp on NGINX with the following configuration:我使用以下配置在 NGINX 上运行我的 webapp:
# Based on https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf
# user www www; ## Default: nobody
worker_processes auto;
error_log "/opt/bitnami/nginx/logs/error.log";
pid "/opt/bitnami/nginx/tmp/nginx.pid";
events {
worker_connections 1024;
}
http {
include 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 "/opt/bitnami/nginx/logs/access.log";
add_header X-Frame-Options SAMEORIGIN;
client_body_temp_path "/opt/bitnami/nginx/tmp/client_body" 1 2;
proxy_temp_path "/opt/bitnami/nginx/tmp/proxy" 1 2;
fastcgi_temp_path "/opt/bitnami/nginx/tmp/fastcgi" 1 2;
scgi_temp_path "/opt/bitnami/nginx/tmp/scgi" 1 2;
uwsgi_temp_path "/opt/bitnami/nginx/tmp/uwsgi" 1 2;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
keepalive_timeout 65;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
client_max_body_size 80M;
server_tokens off;
include "/opt/bitnami/nginx/conf/server_blocks/*.conf";
# HTTP Server
server {
# port to listen on. Can also be set to an IP:PORT
listen 8080;
location /api/* {
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:9999;
}
location /status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
}
and the way that I do the call:以及我打电话的方式:
methods: {
load_user(event) {
console.log(this.$kc)
const config = {
headers: {Authorization: `Bearer ${this.$kc.token}`}
};
this.$axios.get('/api/hello/sali', config)
.then((response) => {
console.log(response)
})
.catch(() => {
console.log("errro")
})
},
Then it shows the following message:然后它显示以下消息:
However, it should return:但是,它应该返回:
What am I doing wrong?我究竟做错了什么?
Not is recomendly that you put your web server inside of nginx configuration, you have that create a file inside of folder sites-enabled .不建议您将web 服务器放在 nginx 配置中,您必须在文件夹sites-enabled中创建一个文件。 And with the main problem:
主要问题是:
In you javascript
code you httpRequest
is pointing to PORT
8090 but the port
that is in nginx-config is 8080在你
javascript
代码中,你的httpRequest
指向PORT
8090但 nginx-config 中的port
是8080
The real problem is in your javascript code try with port 9999 or 8080真正的问题是在您的javascript 代码中尝试使用端口9999或8080
You're listening on port 8080, not 8090, have you tried that?您正在监听端口 8080,而不是 8090,您尝试过吗?
localhost:8080
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.