tannercollin / Notica

Send browser notifications from your terminal. No installation. No registration.
https://notica.us
MIT License
344 stars 22 forks source link

Having slight issues with install on arch with nginx #14

Closed sigmap closed 5 years ago

sigmap commented 5 years ago

I have nginx and yarn installed. trying to use the suggested nginx config is giving me 502's and errors. And when I'm not getting 502's I get Unable to connect to the Notica server. Attempting to reconnect....

Are there any deps I should have in addition to yarn and nginx? And Can I get away without running yarn start? I'm trying to have this running on a small box to push notifications to my desktop when tasks on my server are done.

tannercollin commented 5 years ago

You did yarn install before, right?

Does sound like an nginx issue. Can you post your exact nginx config here?

If you don't want to run yarn start, I recommend supervisor to keep notica running.

sigmap commented 5 years ago

I did yarn install, however it seemed there were files missing and a few errors about webpack deps.

the .conf I have for notica

server {
            listen 80;
            listen [::]:80;

            root /usr/share/webapps/Notica/views/;
            index index.html index.htm;
            types_hash_max_size 4096;
            types_hash_bucket_size 128;

            server_name push.local.server;

           #location / {
        #                proxy_pass http://127.0.0.1:3000/;
        #                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 $scheme;
        #        }

}
sigmap commented 5 years ago

and nginx.conf

#user html;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/conf.d/*.conf;
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {

        listen 80;
        servername local.server;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           /usr/share/nginx/html;
            fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;#127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name; #SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

}
tannercollin commented 5 years ago

server_name needs a semicolon and why's the proxy_pass section commented out?

sigmap commented 5 years ago

If I didn't comment out the proxy_pass section I get a 502 unless I comment out proxy_set_header X-Real-IP $remote_addr; which then gives me a blank, white page.

tannercollin commented 5 years ago

Can you get Notica running with yarn start and confirm with curl http://127.0.0.1:3000/ ?

sigmap commented 5 years ago

I can confirm it is running

...
                                        <div class="twelve columns">
                                                <h4>Javascript Disabled</h4>
                                                <p>
                                                        Uh oh - It looks like Javascript is disabled or not supported in your browser.
                                                        This is bad news for Notica, because we need Javascript to run!
                                                </p>
                                                <p>
                                                        Without it, we are unable to display browser notifications or create a Websocket to our server :(
                                                </p>
                                                <p>
                                                        Please enable Javascript to use Notica. The site looks much prettier with it enabled!
                                                </p>
                                        </div>
                                </div>
                        </div>
                </noscript>
        </body>
</html>
tannercollin commented 5 years ago

Perfect! If it's listening on port 3000, then this nginx config should be all you need:

server {
    listen 80;
    listen [::]:80;

    root /var/www/html;
    index index.html index.htm;

    server_name push.local.server;

    location / {
        proxy_pass http://127.0.0.1:3000/;
        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 $scheme;
    }
}