Welcome! Log In Create A New Profile


nginx proxy_pass https

Posted by renzo 
nginx proxy_pass https
September 13, 2019 11:08AM
i would like to configure my nginx server to be able to make cache via https in direction of a apache server with DNS name but i think it makes only redirection and cache doesnt work

my configuration is
nginx : nginx.com in front
apache : website.com in back

when i put nginx.com ,he makes the redirection but its website.com that appear in the url , dont know if normal and if cache works
here a part of my configuration of nginx.conf

nginx.conf listen on 8080
servername localhost

my proxy.conf file

server {
listen 80;
server_name nginx.com;
location / {
proxy_pass https://website.com;
server {
listen 443;

server_name nginx.com;
#auth_basic "Restricted Access";
#auth_basic_user_file /etc/nginx/htpasswd.users;
ssl on;
ssl_certificate /etc/nginx/nginx.com.pem;
ssl_certificate_key /etc/nginx/nginx.com.pkey;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass https://website.com;
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_cache_valid 301 1m; # Cache permanent redirects for a whole year
proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
resolver website.com;

thanks for help :)
Re: nginx proxy_pass https
September 14, 2019 06:28PM
First of all, whether something issues redirections or actually proxies some other site is easy to tell by hitting F12 in your favourite browser and checking the network requests. With your configuration, I would doubt there is a 301 coming from NGINX.

Second, why do you think this will be caching anything if there is no proxy_cache directive? You should add something like

proxy_cache website_cache;

and define this like

proxy_cache_path /var/cache/nginx/website/ levels=1:2 keys_zone=website_cache:10m max_size=512m inactive=120m use_temp_path=off;

You should then see the cache get populated by replied from the Apache server.

Re: nginx proxy_pass https
September 20, 2019 11:10AM
thx for your reply
effectivly ,now it works , i have my proxy_path file on my nginx server in front which contain the file cache of my apache like this


but my website is still slow and i dont understand how to tell to nginx to put in cache all the static file , i dont know if the configuration is in the nginx.conf or in the proxy.conf for example
i changed my nginx conf like this but same result and my proxy.conf above

server {
servername nginx.com
proxy_pass website.com
location ~* \.(jpg|jpeg|png|gif|ico)$ {
expires 30d;

could someone put me a standard and basic conf for a nginx in front ,apache in back to put static cache ?
by advance,thanks
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 67
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready