Server Fault Asked by Jows on November 10, 2021
The main domain has ssl certificate.
I created a subdomain but I can’t access it in the browser. The browser say “This webpage is not available”. I have same scenario to this post
https://serverfault.com/questions/466636/nginx-subdomain-issue?newreg=3fb69ff76f6c41689ceb296fa5f64abe.
I think my problem is DNS records. But I don’t know how to setup the DNS records in nginx.
Here’s my nginx configuration.
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
server_names_hash_bucket_size 64;
server_name_in_redirect off;
fastcgi_hide_header Server;
fastcgi_hide_header X-Powered-By;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_comp_level 2;
gzip_min_length 1000;
gzip_vary on;
gzip_proxied any;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/javascript;
client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 10;
send_timeout 10;
types_hash_max_size 2048;
client_body_buffer_size 10K;
client_header_buffer_size 10k;
client_max_body_size 16m;
large_client_header_buffers 4 16k;
include /etc/nginx/conf.d/*.conf;
add_header X-Cache $upstream_cache_status;
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=HHVM:100m inactive=10m;
fastcgi_cache_key "$scheme$request_method$host$request_uri?$query_string";
server {
# new ip address catch all according to latest rfc, 444 status code should be returned instead of redirecting to a domain
listen 80 default_server;
return 444;
}
server {
# catch www and redirect it to @
listen 80;
charset utf-8;
server_name www.example.com;
break;
}
server {
charset utf-8;
listen 443 ssl spdy;
server_name mlm.example.com;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
ssl on;
ssl_certificate /etc/ssl/certs/ssl-bundle.crt;
ssl_certificate_key /etc/ssl/private/mlm.example.key;
#enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.
ssl_protocols TLSv1.1 TLSv1.2;
#Disables all weak ciphers
ssl_ciphers "xxxxxxxxxxxxxx";
ssl_prefer_server_ciphers on;
root /usr/share/nginx/html/example/mlm;
index index.php;
set $no_cache 0;
if ($request_method = POST)
{
set $no_cache 1;
}
location ~ .(hh|php)$ {
try_files $uri = 404;
location ~ ..*/.*.php$ {return 404;}
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_keep_conn on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
include /etc/nginx/mime.types;
index index.php;
fastcgi_cache HHVM;
fastcgi_cache_valid 200 10m;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location /wp-admin/ {
set $no_cache 1;
index index.php;
try_files $uri /wp-admin/index.php?$request_uri;
}
}
server{
charset utf-8;
listen 443 ssl spdy;
server_name example.com www.example.com;
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 5m;
ssl on;
ssl_certificate example.crt;
ssl_certificate_key example.key;
ssl_dhparam dhparam.pem;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers "xxxxxxxxxxxxxxx";
ssl_stapling on;
resolver 8.8.8.8;
ssl_trusted_certificate example.crt;
resolver_timeout 10s;
root /usr/share/nginx/html/example;
index index.php;
server_tokens off;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
set $no_cache 0;
if ($request_method = POST)
{
set $no_cache 1;
}
location ~ .(hh|php)$ {
try_files $uri = 404;
location ~ ..*/.*.php$ {return 404;}
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_keep_conn on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
include /etc/nginx/mime.types;
index index.php;
fastcgi_cache HHVM;
fastcgi_cache_valid 200 10m;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location /mysql {
set $no_cache 1;
include /etc/nginx/mime.types;
index /mysql/index.php;
}
location /wp-admin/ {
set $no_cache 1;
index index.php;
try_files $uri /wp-admin/index.php?$request_uri;
}
location ~* .(jpg|jpeg|png|gif|ico|css|js|html|svg|woff|ttf|otf)$ {
add_header Vary Accept-Encoding;
expires max;
access_log off;
}
}
}
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP