passenger_min_instances not working with passenger ruby 2.3 docker - passenger

I am having the following Nginx config in passenger docker ruby phusion/passenger-ruby23 as below
server {
# max body size (request + fileupload)
client_max_body_size 5M;
listen 80;
server_name localhost;
location ~* ^/assets/ {
# if $uri, if not exist then '/404.html'
try_files $uri =404;
expires 1y;
# when Last-Modified is present, ETag is discourage
add_header ETag "";
add_header Cache-Control public;
add_header "Access-Control-Allow-Origin" "*";
add_header "Access-Control-Allow-Methods" "GET";
}
# Nginx serve static assets
root /home/app/avocado/public;
passenger_min_instances 10;
passenger_enabled on;
passenger_user app;
passenger_app_env staging;
passenger_ruby /usr/bin/ruby2.3;
}
The web server runs just fine except that when I ran the command passenger-status I got the following output:
> passenger-status
Using /usr/local/rvm/gems/ruby-2.3.8
Version : 6.0.4
Date : 2020-05-28 10:25:03 +0000
Instance: feaXd0Zv (nginx/1.14.0 Phusion_Passenger/6.0.4)
----------- General information -----------
Max pool size : 6
App groups : 0
Processes : 0
Requests in top-level queue : 0
----------- Application groups ------------
which means Passenger did not start with the min number of process I specified passenger_min_instances 10; in the above config.
Is there anyone experience with this issue?

Just got it working with the following config
server {
...
passenger_min_instances 10;
}
passenger_max_pool_size 15;
passenger_pre_start http://localhost:80;

Related

ubuntu + nginx + laravel vue-material-dashboard

I tried a lot to get the "Vue-material-dashboard Laravel" working. Here is the url to the project.
I manage to serve the thing, but when I try to login and it says: "Invalid credentials".
Looks like this:
As you can see below I also send them a ticket ;) But have not gotten help from them yet, so I decided to see if someone can help me here
Version of Vue-material-dashboard Laravel
latest
Reproduction link
Nginx file:
server {
listen 8080;
index index.php index.html index.htm;
server_name example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
root /data/vue-material-dashboard-laravel/laravel-json-api/public;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
# location ~ /\.(?!well-known).* {
# deny all;
# }
}
Operating System
Ubuntu
Device
server
Browser & Version
firefox, latest
Steps to reproduce
I set all up according to documentation and run npm run build.
I let nginx server the laravel/public folder. I use a rather minimal nginx configration in sites-enabled folder (see nginx code above)
What is expected?
I use the npm command, output tells me to look at http://example.com:8081
Everything looks fine and login should be working with default given login
What is actually happening?
I get some sort of backend, but cannot login.
It says: "Invalid credentials"
Solution
Do you maybe have a nice example of how nginx should server the app?
I could not find anything online. I tried running vue-material-dashboard over https by adding "vue.config.js":
module.exports = {
devServer: {
open: process.platform === 'darwin',
host: '0.0.0.0',
port: 8081, // CHANGE YOUR PORT HERE!
https: true,
hotOnly: false,
},
}
Then indeed everything goes through https but login does still not work. Any ideas why? Seems api does not communicatie well with vue
Additional comments
If we can let it all work on a linux server we woudl want to go and buy the PRO version eventually (after we tested it and so on)

Cache Zend Framework homepage on nginx

I have zend framework 1.12 based site working with nginx
I installed wnmp on windows 7 professional to test Windows, nginx, mariadb, php7
I want to cache home page which is localhost or localhost/
which internally calls index.php using index.php
similarly urls http://localhost/conference/sessions/date/2015-04/12/page/1 conference - controller sessions - action request params date, and page with respective values
I want to cache home page but I have looked but nothing specific is available
Here is my nginx.conf that works without caching
here is what I have in my nginx.conf
worker_processes 1;
error_log logs/error.log;
pid logs/nginx.pid;
events {
# Max value 16384
worker_connections 8192;
# Accept multiple connections
multi_accept on;
}
# Settings that affect all server blocks
http {
include php_processes.conf;
include mime.types;
default_type application/octet-stream;
access_log logs/access.log;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
sendfile on;
keepalive_timeout 65;
ssl_session_timeout 10m;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1 SSLv3;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS;
ssl_prefer_server_ciphers on;
gzip on;
# http server
# Begin HTTP Server
server {
listen 80; # IPv4
server_name localhost;
## Parametrization using hostname of access and log filenames.
access_log logs/localhost_access.log;
error_log logs/localhost_error.log;
## Root and index files.
root html;
index index.php index.html index.htm;
## If no favicon exists return a 204 (no content error).
location = /favicon.ico {
try_files $uri =204;
log_not_found off;
access_log off;
}
## Don't log robots.txt requests.
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
## Try the requested URI as files before handling it to PHP.
location / {
## Regular PHP processing.
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass php_processes;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
## Static files
location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
expires max;
log_not_found off;
## No need to bleed constant updates. Send the all shebang in one
## fell swoop.
tcp_nodelay off;
## Set the OS file cache.
open_file_cache max=1000 inactive=120s;
open_file_cache_valid 45s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
}
## Keep a tab on the 'big' static files.
location ~* ^.+\.(?:ogg|pdf|pptx?)$ {
expires 30d;
## No need to bleed constant updates. Send the all shebang in one
## fell swoop.
tcp_nodelay off;
}
try_files $uri $uri/ #missing;
} # / location
location #missing {
rewrite (.*) /index.php;
}
}
Please help.
Added Under http
note - add two underscores (__) if you cookie starts with and underscore (_)
fastcgi_cache_path /home/k47/cache/nginx levels=1:2 keys_zone=MYHOMEPAGE:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_method$query_string$request_uri$cookie_one$cookie_two$cookie__ga$cookie__gat";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache_valid 200 302 1m;
Under server set a flag/variable which can be used to determine if we need caching or not
I have used other urls to cache and not cache with similar regex
set $no_cache 1;
if ($request_uri ~* "^/$")
{
set $no_cache 0;
}
then finally under location {} I start with
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_cache MYHOMEPAGE;
fastcgi_cache_valid 200 1m;
add_header X-Proxy-Cache $upstream_cache_status;
add_header cache-control 'public, max-age=500';

Nginx Browser Cache expiration not specified

I'm a newbie when it comes to nginx and server config.
I can't seem to set Browser Cache expiration. I don't have a clue on what I did wrong. When I test it on Gtmetrix is says that "expiration not specified". I hope you can help me with this.
# Virtual host file starts here
server {
listen 80;
access_log /var/log/nginx/access.upholsterycleanigs.com.aulog;
error_log /var/log/nginx/error.upholsterycleanings.com.au.log;
server_name upholsterycleanings.com.au www.upholsterycleanings.com.au;
root /home/upholsterycleanings/public_html;
location / {
location ~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|woff|ttf|svg|eot)$ {
expires 30d; #Comment this out if you are using the apache backend cache-control/expires headers.
try_files \$uri \#backend;
}
error_page 405 = \#backend;
error_page 500 = \#custom;
add_header X-Cache "HIT from Backend";
proxy_pass http://172.31.37.201:8181;
include proxy.inc;
}
location \#backend {
internal;
proxy_pass http://172.31.37.201:8181;
include proxy.inc;
}
location \#custom {
internal;
proxy_pass http://172.31.37.201:8181;
include proxy.inc;
}
location ~ .*\.(php|jsp|cgi|pl|py)?\$ {
proxy_pass http://172.31.37.201:8181;
include proxy.inc;
}
location ~ /\.ht {
deny all;
}
}
# Virtual host file ends here
Thank you!

Nginx: increase the number of allowed connections from the same browser

I need your help on tuning a bit Nginx and my server.
I've got a website which is hosted on my server, and an API, also hosted on this server.
The website sends Ajax requests to the API. The problem is, once I've opened a page, which sends Ajax requests to the API, I cannot browse the website anymore using this browser because, I've reached the number of allowed connection for this browser on the website's server.
How can I change Nginx or the server configuration in order to increase the number of connections allowed per browser?
Thanks for your help.
EDIT
Server conf
worker_processes 4;
worker_connections 1024;
multi_accept on;
keepalive_timeout 65;
Server block
server {
listen 80;
server_name mywebsite.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443;
ssl on;
ssl_certificate /path/to/pem;
ssl_certificate_key /path/to/key;
# Set the server name
server_name mywebsite.com;
# add Strict-Transport-Security to prevent man in the middle attacks
add_header Strict-Transport-Security "max-age=31536000";
root /path/to/root/folder;
index index.php;
# Logs
error_log /path/to/error.log;
access_log /path/to/access.log;
# strip app_test.php/ prefix if it is present
rewrite ^/index\.php/?(.*)$ /$1 permanent;
location / {
index index.php;
try_files $uri #rewriteapp;
}
location #rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/(index)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
fastcgi_read_timeout 43200;
internal;
}
# Define error pages
# Error pages are located in the app folder
error_page 403 403.html;
location = 403.html {
root /path/to/error-pages;
internal;
}
error_page 404 404.html;
location = 404.html {
root /path/to/error-pages;
internal;
}
error_page 500 502 503 504 50x.html;
location = 50x.html {
root /path/to/error-pages;
internal;
}
}

Nginx FastCGI Cache $upstream_cache_status; Not Showing

So I have been trying to implement the fastcgi cache on nginx. To test whether the cache is working, I added the header to display the cache status, HIT, MISS, etc using the following line:
add_header X-Cache $upstream_cache_status;
Problem is the header doesn't show up at all. When I hard code a value for the X-Cache header, it shows up though.
My nginx version information:
nginx version: nginx/1.4.6 (Ubuntu) built by gcc 4.8.4 (Ubuntu
4.8.4-2ubuntu1~14.04) TLS SNI support enabled configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module
My site-enabled config:
# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts to this file
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
#move next 4 lines to /etc/nginx/nginx.conf if you want to use fastcgi_cache across many sites
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header updating http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/;
index index.html index.htm index.php;
server_name thinkingtypes.com;
include hhvm.conf;
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
add_header X-Cache $upstream_cache_status;
include fastcgi_params;
fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 60m;
}
location ~ /purge(/.*) {
#fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}
location ~* ^.+\.(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)$ {
access_log off; log_not_found off; expires max;
}
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\. { deny all; access_log off; log_not_found off; }
}
Okay solved the issue myself, HHVM created another file hhvm.conf which handles php files separately though port or sock. I just needed to place the add header there, within that block for it to show up. Anywhere else, the upstream_cache variable was empty as it was not being set, due to the cache not being used.
You can also use nginx module
more_set_headers
by installing this https://github.com/openresty/headers-more-nginx-module#name nginx module.
then add this config to set your nginx header.
more_set_headers 'X-Cached: $upstream_cache_status';

Resources