PATH_INFO variable is always empty when use fastcgi on MacOS - macos

I installed nginx via brew and wrote this simple config for my python app:
server {
server_name localhost;
listen 3000;
location / {
include fastcgi_params;
fastcgi_pass localhost:8082;
}
}
When I start my app on 8082 and try to make any request, I always get response for main page. I found the reason. Flask gets url for matching from enveron PATH_INFO. And in my case this variable is always empty.
I have this problem only on MacOS. This app works well on Linux with same nginx config. What is my mistake?

Related

Deployment of Laravel project on Debian 9 using nginx

I try to deploy my Laravel project from localhost to Debian server using nginx. First of all, i followed this tutorial LINK. Ended at the end of 5. chapter. I did not get any errors. Also I successfully connect Laravel project with server DB. I use Laravel version 6, so when i was modifying newly created config file on /etc/nginx/sites-available/myFile I used laravel's deployment tutorial LINK. As my server does not have any domain, I've got only IP available. Screenshot of my config file:
Config file
When I try to open server page using IP, i got error "This page isn't working". It's because i deleted nginx's default file from sites-enabled. Before, i deleted the default file, i got only default home page of nginx.
I tried to change server_name like server_name _;, server_name "";, server_name IP. After all changes i restarted nginx server.
Any help how to run my Laravel project please? Thank you!!
EDIT: route to project: /var/www/html/OciNaCeste/BP_final
Please use the following configuration
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /var/www/html/OciNaCeste/BP_final/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Then restart nginx

Nginx configuration setup for windows

I am trying to run my vue applications trough nginx on windows and i was using the following tutorials, one to run nginx with AlwaysUp and the other one to configure it.
https://www.coretechnologies.com/products/AlwaysUp/Apps/RunNginxAsAService.html
https://graspingtech.com/nginx-virtual-hosts-ubuntu-16-04/
I also stumbled upon the following stack overflow question which is basically the problem i have but it didnt work:
nginx Windows: setting up sites-available configs
The service is running and recognizes the two domains i am trying to set up but for whatever reason it always sends me back to the NGINX Welcome page and i am not sure what i am doing wrong.
I followed the steps on the second tutorial and did a few changes, such ass adding "server_names_hash_bucket_size 64;" to my nginx.config file. I also created the symlink between the "sites-available" and "sites-enabled directories" using windows mklink.
Here are my files.
Nginx.config
worker_processes 1;
events {
worker_connections 1024;
}
http {
server_names_hash_bucket_size 64;
include mime.types;
default_type application/octet-stream;
include "C:/nginx/nginx/sites-available/*.conf";
sendfile on;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
My app config file in sites-available which also contains a symlink in sites-enabled:
server {
listen 80;
listen [::]:80;
server_name myapp.nginx.br;
root "C:/Users/Documents/git-repository/my-app/dist";
index index.html;
location / {
try_files $uri $uri/ #rewrites;
}
location #rewrites {
rewrite ^(.+)$ /index.html last;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
I also faced the issue how to kill the nginx process. I stumbled a while until I came up with the following command which works:
taskkill /F /FI "IMAGENAME eq nginx.exe"
Well, after many hours i actually found out what was happening.
Everything in my files, from the nginx.conf file to every other .conf files were ok.
However i discovered that when restarting or stop/starting my nginx service with either the AlwaysUp program or the windows service options the service would still be active somehow and wouldnt apply my changes, therefore it would always show me the "welcome to nginx" page.
So i just restarted my computer because i wasnt able to kill the service with conventional means and it worked just fine for every single app i have.
I am sure there is a better way to kill the service and restart it but restarting my computer so the changes to my files would actually be applied solved it.
EDIT: I also discovered that windows takes a little while to stop the nginx service, so if you are using always up try stopping the service there, if it fails try stopping the service trough windows services menu. Also don't forget to set it to manual so you wont accidentally access you nginx app instead of your actual deployed app.

Hosting Laravel Application on Ubuntu Server

I have recently developed my first Laravel application (version 5.2.).
I now want to host the application on my client's server running Ubuntu.
Their admin managed to install and run the native Laravel application on the server which works just fine, however when I come to copy and paste my own application over, the browser returns:
403 Forbidden
nginx/1.4.6 (Ubuntu)
Accessing the public folder directly (www.example.com/public/index.php) the browser returns:
The www.example.com page isn’t working
www.example.com is currently unable to handle this request.
HTTP ERROR 500
Can anybody please help me out with the proper method of hosting my application?
Seems more like an nginx-problem. Try to change your nginx virtualhost config to this.
server {
listen 80;
server_name yoursite.tld
root /var/www/yoursite/public/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
First save your file inside,
var/www/html/
Then using Terminal go to your folder
cd var/www/html/your_folder
Run Laravel application
sudo php -S localhost:8888 -t public
Make sure your port number is not same as the other Laravel instance running in the server.

Don't think I have php setup right in nginx virtual host configs

I'm trying to install magento php ecommerce on a virtual server that previously did not have php. When I put simple php pages into a directory they run (for example I have index.php run phpinfo). But when I try to run the magento setup scripts they bomb out without outputting an error. I have two other virtual servers through a different service (running apache) and when I drop the magento files into them the setup pages light up right away and start checking requirements. On my nginx server the only output is a small grey box, but no error output.
My best guess is that I have not configured nginx virtual hosts properly for php.
I am on php5.5 using fpm on Ubuntu 12.04. I don't run a default file in sites-enabled, just two vhost files. Here's the vhost in question (the other site is working fine, but it's python):
server {
listen 80;
listen [::]:80;
#
server_name magento.mydomain.com;
#
root /var/www/magento.mydomain.com/public_html;
index index.php index.html index.htm;
#
# location / {
# try_files $uri $uri/ /index.php =404;
# }
# location / {
# /index.php;
# }
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:8070;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/magento.mydomain.com/public_html/$fastcgi_script_name;
}
}
You can see my commented out location / directives. I have tried those is various fashion. My hunch was that magento was calling php with directory names only (instead of somedir/index.php) so I was messing with those, but it seems like that would be handled by the index directive before the locations.
I'm pretty green with nginx. Does anyone see anything obvious?

404 running Mvc3 with Mono on Raspberry Pi with Nginx and FastCgi

After lots and lots of hours put into configuring, formatting, reformatting, googling and reading what seems like hundred tutorials I still havent been able to run a MVC3 application on Raspberry Pi.
When I try to access it it throws a 404 error regardless if I try to access it via http://network_ip or http://network_ip/Home/Index
(source: shrani.si)
It does the same whether accessed from Nginx or XSP4 server.
My configuration:
nginx
server {
listen 80; ## listen for ipv4; this line is default and implied
root /var/www;
# Make site accessible from http://localhost/
server_name localhost;
access_log /var/log/nginx/localhost.log;
location / {
root /var/www/;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_index Home/Index;
include /etc/nginx/fastcgi_params;
}
}
MVC3 app should be deployed correctly (deleted Entity Framework references, copied Mvc references).
Im running Mono 2.10.8.1
Thank you

Resources