Forum Moderators: phranque

Message Too Old, No Replies

How are HTTP Headers set in nginx

         

darb

4:44 am on Feb 21, 2019 (gmt 0)

5+ Year Member



Greetings all,

Where/how can I set/change the header response code in apache/nginx.

I am on shared hosting and it is just easier to find the answer myself ....

Example: [ibb.co...]

Thanks!

not2easy

4:58 am on Feb 21, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hi darb and Welcome to WebmasterWorld [webmasterworld.com]

The server response is set by the server depending on the request and the result of the request so the question is a little too general to get a definitive response. I could guess that you would prefer to see a 301 response for a page which as been replaced rather than a 404? If we understand the context better, you will have a more useful answer.

Generally speaking, things that can affect the server response could be error documents or rules in your .htaccess file.

phranque

10:30 am on Feb 21, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, darb!

regarding how headers are set in nginx, refer to the following documentation on the add_header directive:
[nginx.org...]

how you get a specific status code for the response depends on which type of response you are looking for.

darb

5:22 pm on Feb 21, 2019 (gmt 0)

5+ Year Member



I am looking to get rid of the 301 and get 200s including on a bunch of parked domains.

not2easy

2:59 am on Feb 22, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



The only way to have a 200 response on a parked domain is to put content on that parked domain. If it is only used to redirect traffic, it will return a 301 or a 302 header.

phranque

3:30 am on Feb 22, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I am looking to get rid of the 301 and get 200s including on a bunch of parked domains.

are you hosting those parked domains or is your registrar doing that?

if the 301 was created by your nginx server, you should look for the use of "return" or "rewrite" directives:
[nginx.org...]

lucy24

3:34 am on Feb 22, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I am looking to get rid of the 301
Where did the 301 come from in the first place? They don't just spring up like mushrooms; someone somewhere has to have instituted that redirect. In the circumstances, that “someone somewhere” may very well have been yourself, clicking the button that says “This is a parked domain”, and now you can’t remember where the button was in order to unclick it.

We don’t have a(n)* nginx subforum, do we? Just Apache and That Other Server.

* I believe it’s officially pronounced engine-X, but I always read it as beginning with the velar nasal, which these forums won’t allow me to write except with the “ng” digraph.

tangor

3:38 am on Feb 22, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



@darb ... Howdy!

What @phranque said.

darb

8:43 pm on Feb 24, 2019 (gmt 0)

5+ Year Member



Where did the 301 come from in the first place? They don't just spring up like mushrooms; someone somewhere has to have instituted that redirect. In the circumstances, that “someone somewhere” may very well have been yourself, clicking the button that says “This is a parked domain”, and now you can’t remember where the button was in order to unclick it.


Thats why I am here; where is the 301 set, how do I change it? So it is specifically caused by my action? I think you must work for my hosting company?

We don’t have a(n)* nginx subforum, do we? Just Apache and That Other Server.


Just to clarify it is apache webserver and nginx cache.

The only way to have a 200 response on a parked domain is to put content on that parked domain. If it is only used to redirect traffic, it will return a 301 or a 302 header.


Yes, there is a domain specific generated page for each parked domain. 301 is still being generated for live active domains that have been up for weeks, not just parked domains.

are you hosting those parked domains or is your registrar doing that?

if the 301 was created by your nginx server, you should look for the use of "return" or "rewrite" directives:


I am hosting them; I am not sure if it is apache or nginx that is generating the header code?

lucy24

10:21 pm on Feb 24, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



When you look at raw logs, are they apache logs or nginx logs? When a request comes in for one of the parked domains, where has the DNS told it to go? Is the host also the registrar and/or DNS?

If you originally created the redirect by clicking a button somewhere in your host's control panel, the only way to remove it is to find the button you clicked, and un-click it.

:: trying to avoid asking why “a bunch of” parked domains exist in the first place ::

tangor

11:33 pm on Feb 24, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



^^^ If parked, what action are you seeking to obtain? Parked is pretty much a dead end, no content, etc.

IOW, why worry?

phranque

3:29 am on Feb 25, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Thats why I am here; where is the 301 set, how do I change it? So it is specifically caused by my action?

Just to clarify it is apache webserver and nginx cache.

start by finding the 301 in a web server access log file.
if you find the 301 in the nginx access log, see my previous response above.
if you find the 301 in the apache access log, look at your .htaccess file. otherwise it is in a server config file. or perhaps the request is being internally rewritten to an application script which is generating the 301 response.