I install nginx 1.13.10 with a wordpress site and openssl on my virtual machine. I'm trying to test http2 push. Here is my nginx conf file:
pastebin.com/71ziXeRh
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 192.168.133.21;
return 302 https://$server_name$request_uri;
}
# Load configuration files for the default server block.
server {
listen 443 ssl http2;
server_name 192.168.133.21;
include conf.d/self-signed.conf; #ssl config
ssl on;
location / {
root /var/www/wordpress/current;
index index.php index.html index.htm;
http2_push /wp-content/themes/twentyseventeen/assets/images/header.jpg;
http2_push /wp-content/themes/twentyseventeen/style.css?ver=4.7.4;
}
error_page 404 /404.html;
location = /40x.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root /var/www/wordpress/current;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Restart nginx and no error. But when I debug it with Chrome no resource was pushed demo image
Please tell me if I do something wrong somewhere.
It's a restriction in Chrome. If your SSL/TLS cert is not trusted (as we can see yours is not in the screenshot) it ignores pushed resources. Even if you skip paste the HTTPS error. Similarly resources on such a site cannot be cached.
Add the certificate to your browser's trust store so you get a green padlock and it should start to work.
Similar question (but using Node rather than Nginx) here.
Related
I want to add a domain manually with cli of centos 7 and created a config file in sites-available directory:
server {
listen 80;
server_name hustana.ir www.hustana.ir;
location / {
root /home/www/public_html;
index index.html index.htm;
try_files $uri $uri/ =404;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
In my server there is another domains that are online and works fine.
if its help I should tell that at start my server was worked by Plesk Obtisian control panel
but now I wanna add another domain to server just but it`s not working.
I changed my domain NS from domain control center.
additional description:
I guess it`s good to say that if I delete the config block of one of my older domains , domain still stay online but it displays just a blank white page.
I tried add to include this config file from another directory directly into nginx.conf:
server {
listen 80;
server_name hustana.ir;
root /home/www/public_html;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
You need to enable your site as mentioned here.
Check the A-record of your domain. It must point to your server IP.
Hey everyone!
I'm having a really hard time figuring this out, when i run my website with apache, everything works as intended, however i recently switched to nginx, when i run my website on nginx and access the joomla backend i get an Error 520 from Cloudflare, i can't find out the difference in the two webservers, but it seems related to SSL, running without SSL works fine.
I'm out of luck i did a lot of testing and still the same issue.
Something that Cloudflare cannot understand is happening when using Nginx.
This is my Nginx Config
server {
listen 443 ssl http2;
listen 80;
server_name websitename.com www.websitename.com;
root /var/www/html;
ssl_certificate websitename.com.crt;
ssl_certificate_key websitename.com.key;
index index.php index.html index.htm default.html default.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi.conf;
}
location ~* \.(ico|pdf|flv)$ {
expires 1y;
}
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
expires 14d;
}
}
Finally i solved it.
Finally i found out that somehow the Cloudflare Railgun isn't behaving right with Nginx
I went to Cloudflare and navigated to "Speed->Optimizations" I disabled the Railgun
and i no longer have 520 Errors.
Hope this helps anyone with the same issue, been 3 days stuck on this.
I have multiple domains registered at on service provider and hosting on linode with nginx.
The example of domain name is www.example.com (not example.com)
All the domains are working fine with www but without it the page does not load.
In curl -I http://example.com
it results
curl: (6) Could not resolve host http://example.com
I have 3 A/AAAA Records for each separately
blank IP
mail IP
www IP
In my /etc/nginx/sites-available
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
access_log /var/log/nginx/example.com.log;
error_log /var/log/nginx/example.com-error error;
root /var/www/examplecom/public;
index index.html index.php;
location ~ \.php?$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php-main.socket;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_split_path_info ^(.+\.php)(.*)$;
#Prevent version info leakage
fastcgi_hide_header X-Powered-By;
}
}
server {
listen 80;
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
I have also tried by writing the second server block on top but same result.
Kindly immediate guideline/help is required.
Thank you guys for response.
By the way the problem was resolved when I changed my domain name in linode settings from www.example.com to example.com
I am developing a website, and I just installed ssl on the production website (I have never done this before). When I load the development website the page redirects to https and breaks because https isn't installed on the development site.
Development url: http://local.ezel.io
Production url: https://ezel.io
The Nginx (production):
server{
listen 80;
server_name ezel.io;
root /var/www/ezel.io/public;
location ~ /.well-known {
allow all;
}
rewrite ^ https://$server_name$request_uri? permanent;
}
The Nginx (development):
server {
listen 80;
server_name local.ezel.io;
root /home/ryan/Documents/www/ezel.io/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
On my development machine, I also have the following in my hosts file:
127.0.0.1 local.ezel.io
What would be causing me to go from http://local.ezel.io to https://local.ezel.io?
I think the problem is that you enabled https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security once and now your browser insists on trying HTTPS.
Try this: http://classically.me/blogs/how-clear-hsts-settings-major-browsers
Also, try pinging local.ezel.io to ensure it's really your localhost and not actually ezel.io.
I want to have two servers on my machine, one private, accessible only locally on 127.0.0.1 and one which is visible on LAN (it's root folder is subfolder of the private server). So I have made two configuration files in sites-available and linked them to sites-enabled folder. File accessible:
server {
listen 80;
root /usr/share/nginx/html/accessible/;
index index.php index.html index.htm;
server_name accessible;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html/accessible/;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
and file localhost:
server {
listen 127.0.0.1:80;
listen [::1]:80;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
After that I have updated /etc/hosts so that http://accessible/ is forwarded to 127.0.0.1: 127.0.0.1 accessible is the line.
Now when I try to connect to http://localhost/, everything is ok, I get /usr/share/nginx/html/index.html as expected. But when I try to connect to http://accessible/ The same file /usr/share/nginx/html/index.html is displayed. How is that possible? The root folders are apparently set.
The problem is that localhost server operates on the same IP as I have configured for accessible to be redirected to which is apparently not possible (or at least I don't know how).
I have redirected accessible to 127.0.0.2 (changed line in /etc/hosts to 127.0.0.2 accessible) which is another address served by local machine and after small change in nginx config file accessible that allowed all LAN IP addresses (allow 192.168.1.0/32;) everything works just fine (for me on local machine and for computers on network).