nginx-设置React App和Flask具有不同的端口号码
我有一个react应用程序可以在
烧瓶API在
中 运行当导航到 www.domain.io 时,将显示React应用程序。 href =“ http://www.domain.io:5000” rel =“ nofollow noreferrer”> www.domain.io:5000 。
我如何设置nginx服务器块,以便React App和Blask API可以在?
这是我的服务器块
ssl_certificate /etc/letsencrypt/live/twitterlicious.io/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/twitterlicious.io/privkey.pem; # managed by Certbot
#include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
#ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
server{
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name twitterlicious.io www.twitterlicious.io;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
#proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection 'upgrade';
#proxy_set_header Host $host;
#proxy_cache_bypass $http_upgrade;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
}
server {
listen 5000;
location /{
proxy_pass http://localhost:5000;
}
}
server {
if ($host = www.twitterlicious.io) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = twitterlicious.io) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name twitterlicious.io www.twitterlicious.io;
return 404; # managed by Certbot
}
任何帮助。谢谢!
I have the react app to run on
And the Flask API is running on
The React app is shown when navigated to www.domain.io, but it's having trouble talking to the API on www.domain.io:5000.
How can I set the NGINX server block so the React app and Flask API can co-exist under www.domain.io?
Here is my server block
ssl_certificate /etc/letsencrypt/live/twitterlicious.io/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/twitterlicious.io/privkey.pem; # managed by Certbot
#include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
#ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
server{
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name twitterlicious.io www.twitterlicious.io;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
#proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection 'upgrade';
#proxy_set_header Host $host;
#proxy_cache_bypass $http_upgrade;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
}
server {
listen 5000;
location /{
proxy_pass http://localhost:5000;
}
}
server {
if ($host = www.twitterlicious.io) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = twitterlicious.io) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name twitterlicious.io www.twitterlicious.io;
return 404; # managed by Certbot
}
Any help is appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论