I'm trying to deploy a web application to my server.
(我正在尝试将Web应用程序部署到服务器上。)
I have put the html files in one folder and I have a django server running on the same server. (我将html文件放在一个文件夹中,并且我在同一台服务器上运行了django服务器。)
I am using nginx to set up reverse proxy for the backend but for some reason I'm not able to route to backend urls. (我正在使用nginx为后端设置反向代理,但是由于某些原因,我无法路由到后端url。)
Here is my nginx configuration:
(这是我的nginx配置:)
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://example.com$request_uri;
}
server {
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
server_name example.com example.com;
root /var/www/html/;
index index.html;
# Let's Encrypt parameters
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
try_files $uri $uri/ = index.html;
}
location /api {
proxy_pass http://unix:/run/gunicorn.sock;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
}
In the first block..I'm setting fallbacks to index.html because it is an angular app.
(在第一个程序段中。我将备用设置为index.html,因为它是一个有角度的应用程序。)
The angular app runs fine. (角度应用程序运行正常。)
But I'm not able to access the routes of the reverse proxy server, whenever I hit a route with /api/something it takes me back to the angular app ie index.html
(但是,每当我使用/ api / something命中一条路由时,我就无法访问反向代理服务器的路由,这会使我回到有角度的应用程序,即index.html)
ask by Goutam B Seervi translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…