我尝试使用nginx设置反向代理,并在进行了更改之后,查看API的json数据的页面(www.ourapihost.com/issues.json)现在因错误< / p>
We're sorry but something went wrong. If you are the application owner check the logs for more information.
但是,日志为空白。我必须清除它们,因为需要花费太多时间来整理日志文件,但是当我尝试刷新页面时,它会因上述错误而不断超时,并且没有在日志中添加任何内容。
这是我们当前的nginx配置:
server {
listen 80; #443 ssl http2;
server_name <our server domain>;
root /home/deployer/ft_parks/current/public;
access_log /var/log/nginx/wilderness-patrol.net_access.log;
# error_log /var/log/nginx/wilderness-patrol.net_error.log;
client_max_body_size 4M;
client_body_buffer_size 128k;
keepalive_timeout 200;
error_page 500 502 503 504 /500.html;
try_files $uri @app;
# include /etc/nginx/snippets/letsencrypt-acme-challenge.conf;
open_file_cache max=2000 inactive=20s;
open_file_cache_valid 60s;
open_file_cache_min_uses 5;
open_file_cache_errors off;
location @app {
proxy_pass http://wp_server;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
# location /issues {
# add_header 'Access-Control-Allow-Origin' '*';
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
# add_header 'Access-Control-Allow-Headers' 'User-Agent,Keep-Alive,Content-Type';
# add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
# proxy_pass http://<my ip>:3001/;
# }
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml|svg)$ {
access_log off;
log_not_found off;
expires 30d;
}
}
location = /500.html {
root /home/deployer/ft_parks/current/public;
}
}
已注释掉的location /issues
块是我添加的尝试添加反向代理的部分。我的webpack服务器正在localhost:3001上运行。
我在这里阅读了有关此问题的其他一些有关stackoverflow的相关文章,并尝试了他们建议的所有解决方案,但是没有一个对我有用。我感觉自己在location /issues
块中丢失了某些内容,或者只是只是没有正确地编写它而已。我也已经尝试使用rack-cors gem,但我也无法使用。
有什么建议吗?谢谢!