April
6th,
2019
upstream proxy
upstream fvlandingpagebygeo_phoenix {
server 127.0.0.1:8900
}
server {
server_name fvlandingpagebygeo.com www.fvlandingpagebygeo.com;
listen 80 default_server;
listen [::]:80 default_server;
root /srv/www/fvlandingpagebygeo.com/htdocs;
index index.html;
location / {
# pass the requests on to our proxy
try_files $uri @proxy;
}
location @proxy {
include proxy_params;
proxy_redirect off;
proxy_pass http://fvlandingpagebygeo_phoenix;
}
}
phoenix应用作为子目录
- nginx配置
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
location ~ /(phx|phoenix) {
proxy_pass http://127.0.0.1:4000;
# Proxy Headers
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Cluster-Client-Ip $remote_addr;
# WebSockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
- any compiled assets need to be prefixed with the subdirectory
- any reference to those assets needs to be prefixed with the subdirectory
- all links should be prefixed with the subdirector
参考
Hosting A Phoenix App In A Subdirectory With Nginx