Quantcast
Channel: linuxadmin: Expanding Linux SysAdmin knowledge
Viewing all articles
Browse latest Browse all 17924

nginx + php + reverse proxy + https? halp?

$
0
0

Edit 1: Found the solution for the remote php that nginx was trying to proces, code updated

Hi friends!

I'm back again thankful for all the help I had from this community previously. I'd like some help with the following. I have an nginx server running on ubuntu. So far it's doing the basic. PHP+Webserver. Great. Now I want it to do MUCH more for me.

I have a set of other webservers running and I'd like to be able to access them through a "Portal", I'd want to use NAT to open one http server to the outside world. (I'll upgrade to https eventually).

I'd like to be able to access the server "root" directly. http://myservername.com should serve a standard php file.Fixed

2. I'd like to forward sub directories into other webservers I have running http://myservername.com/proxy should go and reverse proxy another server I have on my network: http://miniserver/;Fixed

  1. I would also really like "authentication" when a first request is made to any of the proxied services
  2. I'd like to forward sub directories into other webservers that run https
  3. My root is root /var/www/html, however I want http://myservername.com/weirdservice to be able to access php files and have rw access /somedir/somestuff and be locked to it. (no directory traversal)
  4. I would like it to be done "well" and "elegantly" I want to follow conventions and proper ways of doing things since I eventually want to add even more services to reverse proxy. (maybe include files... so far i'm using one ugly /etc/nginx/sites-available )

Testing the following if i access http://myserver/proxy it shows the page fine but if i do include http://myserver/proxy/index.php then it don' work no mo'. nginx tries to process the php file. No bueno.Fixed

Any help is welcome!

server { listen 80 default_server; root /var/www/html; index index.html index.htm index.nginx-debian.html index.php; server_name _; location / { try_files $uri $uri/ /index.html; } **utorrent doesnt work just gets stuck at the "loading" page** location ^~ /utorrent/ { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; real_ip_header X-Forwarded-For; proxy_buffering off; proxy_pass http://workstation:8080/gui/; proxy_redirect off; } location ^~ /proxy/ { proxy_pass http://miniserver/; } **this one is a https server so that does not work either it simply redirects** location ^~ /freenas/ { proxy_pass http://freenas/; } **this one is a https server so that does not work either it simply redirects** location ^~ /pfsense/ { proxy_pass http://pfsense/; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } ##############THIS IS THE OLD VERSION IGNORE#################### server { listen 80 default_server; root /var/www/html; index index.html index.htm index.nginx-debian.html index.php; server_name _; location / { try_files $uri $uri/ /index.html; } location /proxy/ { rewrite /proxy/(.*) /$1 break; proxy_buffering off; proxy_pass http://miniserver/; proxy_redirect default; } location ~ \.php$ { #root /var/www/html; #try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } 
submitted by yan_imagined_it
[link][7 comments]

Viewing all articles
Browse latest Browse all 17924

Latest Images

Trending Articles



Latest Images