dina

dina

Im trying to deploy the sample phoenix app on my Linode server but it doesn’t seem to work, I suspect the issue is in the Nginx config.

When I use port forwarding to forward all the traffic from port 80 to 4000
firewall-cmd --add-forward-port=port=80:proto=tcp:toport=4000
the phoenix page is loaded so the parameters in the phoenix app must be configured properly.

I have a few sites hosted on the same server therefor I must use the Nginx.

The complete Nginx config located in /sites-available/phoenix is

server {
    listen 80;
    server_name www.mydomain.com;
    root /var/www/phoenix1/priv/static;
    access_log /var/log/nginx/phoenix.access.log;
    error_log /var/log/nginx/phoenix.error.log;
    client_max_body_size 12M;

    location / {
     index index.html
     try_files $uri @app;
    }

    location @app{
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_cache_bypass $http_upgrade;
      proxy_set_header Host               $host;
      proxy_set_header X-Real-IP          $remote_addr;
      proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
      proxy_set_header Refrerer           $http_referer;
      proxy_set_header User-Agent         $http_user_agent;
      limit_req zone=phoenix burst=5 nodelay;
      proxy_pass "http://localhost:4000";
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
    location = /robots.txt {
       allow all;
        log_not_found off;
        access_log off;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/www;
    }
    location ~ /.well-known {
        allow all;
    }

    location ~ /\. {
        deny all;
    }
    location ~* ^.+\.(js|css|swf|xml|txt|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
        add_header Cache-Control public;
        access_log off; log_not_found off; expires 30d;
    }
    location ~* /(?:uploads|files)/.*\.*$ {
        deny all;
    }
}

the nginx.conf content is

worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
    use epoll;
    multi_accept on;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        limit_req_zone $binary_remote_addr zone=phoenix:10m rate=1r/s;
        limit_req_status 429;
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        gzip on;
        gzip_disable "msie6";
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

Showing Posts 1 to 4

ehayun

ehayun

This work fro me with no problem
proxy on 4000 to 80

upstream phoenix {
  server 127.0.0.1:4000 max_fails=5 fail_timeout=60s;
}

server {
	server_name  iex.venus.home;
	listen 80;

	client_max_body_size 30M;
	location / {
		allow all;

# Proxy Headers
		proxy_http_version 1.1;
		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;

# The Important Websocket Bits!
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";

		proxy_pass http://phoenix;
	}
}
dina

dina OP

great thanks for your help.
I set my nginx config as you suggested and removed all the other unnecessary staff, now it works

bbte

bbte

What about SSL?

ehayun

ehayun

I am using https://letsencrypt.org/
It’s adding the necessary code for me on production
work fine

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews